env_timed_test.cc 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #include "rocksdb/env.h"
  6. #include "rocksdb/perf_context.h"
  7. #include "test_util/testharness.h"
  8. namespace ROCKSDB_NAMESPACE {
  9. class TimedEnvTest : public testing::Test {};
  10. TEST_F(TimedEnvTest, BasicTest) {
  11. SetPerfLevel(PerfLevel::kEnableTime);
  12. ASSERT_EQ(0, get_perf_context()->env_new_writable_file_nanos);
  13. std::unique_ptr<Env> mem_env(NewMemEnv(Env::Default()));
  14. std::unique_ptr<Env> timed_env(NewTimedEnv(mem_env.get()));
  15. std::unique_ptr<WritableFile> writable_file;
  16. ASSERT_OK(timed_env->NewWritableFile("f", &writable_file, EnvOptions()));
  17. ASSERT_GT(get_perf_context()->env_new_writable_file_nanos, 0);
  18. }
  19. } // namespace ROCKSDB_NAMESPACE
  20. int main(int argc, char** argv) {
  21. ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
  22. ::testing::InitGoogleTest(&argc, argv);
  23. return RUN_ALL_TESTS();
  24. }