env_timed_test.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifndef ROCKSDB_LITE
  6. #include "rocksdb/env.h"
  7. #include "rocksdb/perf_context.h"
  8. #include "test_util/testharness.h"
  9. namespace ROCKSDB_NAMESPACE {
  10. class TimedEnvTest : public testing::Test {
  11. };
  12. TEST_F(TimedEnvTest, BasicTest) {
  13. SetPerfLevel(PerfLevel::kEnableTime);
  14. ASSERT_EQ(0, get_perf_context()->env_new_writable_file_nanos);
  15. std::unique_ptr<Env> mem_env(NewMemEnv(Env::Default()));
  16. std::unique_ptr<Env> timed_env(NewTimedEnv(mem_env.get()));
  17. std::unique_ptr<WritableFile> writable_file;
  18. timed_env->NewWritableFile("f", &writable_file, EnvOptions());
  19. ASSERT_GT(get_perf_context()->env_new_writable_file_nanos, 0);
  20. }
  21. } // namespace ROCKSDB_NAMESPACE
  22. int main(int argc, char** argv) {
  23. ::testing::InitGoogleTest(&argc, argv);
  24. return RUN_ALL_TESTS();
  25. }
  26. #else // ROCKSDB_LITE
  27. #include <stdio.h>
  28. int main(int /*argc*/, char** /*argv*/) {
  29. fprintf(stderr, "SKIPPED as TimedEnv is not supported in ROCKSDB_LITE\n");
  30. return 0;
  31. }
  32. #endif // ROCKSDB_LITE