I am trying to understand and benchmark fmt::format API ( https://fmt.dev/latest/api.html ). I wrote a simple test in compiler explorer i.e, https://godbolt.org/z/fMcf3nczE.
#include <benchmark/benchmark.h>
#include <fmt/core.h>
static void BM_format(benchmark::State& state) {
// Perform setup here
for (auto _ : state)
{
std::string s = fmt::format( "{}", "testing fmt::format in benchmark");
}
}
// Register the function as a benchmark
BENCHMARK(BM_format);
// Run the benchmark
BENCHMARK_MAIN();
Then, I launched quick-bench from compile explorer. In quick-bench, it gives an error as
Error or timeout bench-file.cpp:2:10: fatal error: fmt/core.h: No such file or directory 2 | #include <fmt/core.h> | ^~~~~~~~~~~~ compilation terminated.
Is the c++ fmt library supported in quick-bench so that it compiles and executes? if not, any alternative.
Unfortunately, quick-bench does not support external libraries which require separate compilation (as fmt does). As a side note, it does not support the inclusion of header-only libraries via URLs, either.
I would have said that in this specific case you could use C++20 std::format
instead, if you are not tied to fmt lib specifically. But unfortunately, neither clang 14 nor gcc 11 (or rather, libc++ and libstdc++) have implemented it yet.
So I fear what you ask is simply impossible right now. You need to benchmark on your own computer.