From 217bde267421fcde487351b42f31025159e79e92 Mon Sep 17 00:00:00 2001 From: mutouyun Date: Sun, 4 Dec 2022 19:19:48 +0800 Subject: [PATCH] upd: optimize benchmark --- benchmark/benchmark_fmt.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/benchmark/benchmark_fmt.cpp b/benchmark/benchmark_fmt.cpp index 8017544..186bae2 100644 --- a/benchmark/benchmark_fmt.cpp +++ b/benchmark/benchmark_fmt.cpp @@ -83,14 +83,16 @@ void fmt_multi_fmt_float(benchmark::State &state) { } void imp_fmt_chrono(benchmark::State &state) { + auto now = std::chrono::system_clock::now(); for (auto _ : state) { - std::ignore = imp::fmt(std::chrono::system_clock::now()); + std::ignore = imp::fmt(now); } } void fmt_fmt_chrono(benchmark::State &state) { + auto now = std::chrono::system_clock::now(); for (auto _ : state) { - std::ignore = fmt::format("{}", std::chrono::system_clock::now()); + std::ignore = fmt::format("{}", now); } }