mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 10:01:33 +08:00
Updated latency tests
This commit is contained in:
parent
34c60e5486
commit
971c1f46b0
@ -1,27 +1,27 @@
|
||||
CXX ?= g++
|
||||
CXXFLAGS = -march=native -Wall -Wextra -pedantic -Wconversion -std=c++11 -pthread -I../include -fmax-errors=1
|
||||
CXXFLAGS = -march=native -Wall -Wextra -pedantic -Wconversion -std=c++11 -pthread -I../include -fmax-errors=1
|
||||
CXX_RELEASE_FLAGS = -O3 -flto -Wl,--no-as-needed
|
||||
|
||||
|
||||
binaries=padder_bench
|
||||
binaries=bench.cpp async_bench latency padder_bench
|
||||
|
||||
all: $(binaries)
|
||||
|
||||
bench: bench.cpp
|
||||
$(CXX) bench.cpp -o bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
||||
|
||||
|
||||
|
||||
async_bench: async_bench.cpp
|
||||
$(CXX) async_bench.cpp -o async_bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
||||
|
||||
|
||||
|
||||
|
||||
latency: latency.cpp
|
||||
$(CXX) latency.cpp -o latency $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -lbenchmark
|
||||
|
||||
|
||||
padder_bench: padder_bench.cpp
|
||||
$(CXX) padder_bench.cpp -o padder_bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -lbenchmark
|
||||
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
|
@ -59,6 +59,18 @@ void bench_logger(benchmark::State &state, std::shared_ptr<spdlog::logger> logge
|
||||
}
|
||||
}
|
||||
|
||||
void bench_disabled_macro(benchmark::State &state, std::shared_ptr<spdlog::logger> logger)
|
||||
{
|
||||
int i = 0;
|
||||
benchmark::DoNotOptimize(i); //prevent unused warnings
|
||||
benchmark::DoNotOptimize(logger); //prevent unused warnings
|
||||
for (auto _ : state)
|
||||
{
|
||||
SPDLOG_LOGGER_DEBUG(logger, "Hello logger: msg number {}...............", i++);
|
||||
SPDLOG_DEBUG("Hello logger: msg number {}...............", i++);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
@ -74,14 +86,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
prepare_logdir();
|
||||
|
||||
// Single threaded benchmarks
|
||||
// disabled loggers
|
||||
auto disabled_logger = std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_mt>());
|
||||
disabled_logger->set_level(spdlog::level::off);
|
||||
benchmark::RegisterBenchmark("disabled-level", bench_logger, disabled_logger)->UseRealTime();
|
||||
benchmark::RegisterBenchmark("disabled-at-compile-time", bench_disabled_macro, disabled_logger);
|
||||
benchmark::RegisterBenchmark("disabled-at-runtime", bench_logger, disabled_logger);
|
||||
|
||||
auto null_logger_st = std::make_shared<spdlog::logger>("bench", std::make_shared<null_sink_st>());
|
||||
benchmark::RegisterBenchmark("null_sink_st (500_bytes c_str)", bench_c_string, std::move(null_logger_st))->UseRealTime();
|
||||
|
||||
benchmark::RegisterBenchmark("null_sink_st (500_bytes c_str)", bench_c_string, std::move(null_logger_st));
|
||||
benchmark::RegisterBenchmark("null_sink_st", bench_logger, null_logger_st);
|
||||
|
||||
// basic_st
|
||||
|
Loading…
Reference in New Issue
Block a user