|
29 | 29 |
|
30 | 30 | #include "gtest/gtest.h" |
31 | 31 | #include "spdlog/common.h" |
| 32 | +#include "utils/flags.h" |
32 | 33 | #include "utils/fmt_logging.h" |
33 | 34 | #include "utils/timer.h" |
34 | 35 |
|
35 | 36 | TEST(LoggingTest, LOG) { LOG(spdlog::level::info, "in TEST(LoggingTest, GlobalLog)"); } |
36 | 37 |
|
| 38 | +DSN_DEFINE_int32(test, |
| 39 | + logging_test_simple_benchmark_loops, |
| 40 | + 10, |
| 41 | + "The loop times for LoggingTest.SimpleBenchmark test case"); |
| 42 | + |
37 | 43 | TEST(LoggingTest, LOGWithBigString) |
38 | 44 | { |
39 | 45 | std::string big_str(128000, 'x'); |
@@ -80,3 +86,18 @@ TEST(LoggingTest, TestLogTiming) |
80 | 86 |
|
81 | 87 | ASSERT_EQ("hello", s2); |
82 | 88 | } |
| 89 | + |
| 90 | +TEST(LoggingTest, SimpleBenchmark) |
| 91 | +{ |
| 92 | + g_stderr_logger->set_level(spdlog::level::critical); |
| 93 | + g_file_logger->set_level(spdlog::level::debug); |
| 94 | + SCOPED_LOG_TIMING(info, |
| 95 | + "LoggingTest.SimpleBenchmark loop {} times", |
| 96 | + FLAGS_logging_test_simple_benchmark_loops); |
| 97 | + for (int i = 0; i < FLAGS_logging_test_simple_benchmark_loops; i++) { |
| 98 | + LOG_DEBUG("abc {}, {}, {}", i, 1.0, "hello 1"); |
| 99 | + LOG_INFO("abc {}, {}, {}", i + 1, 2.0, "hello 2"); |
| 100 | + LOG_WARNING("abc {}, {}, {}", i + 2, 3.0, "hello 3"); |
| 101 | + LOG_ERROR("abc {}, {}, {}", i + 3, 4.0, "hello 4"); |
| 102 | + } |
| 103 | +} |
0 commit comments