Benchmarking against FastFormat
eli-b opened this issue · 1 comments
I would like to contribute support for benchmarking against FastFormat.
My motivation is that my single-threaded app writes huge csv files and seems to be cpu bound.
I'm currently using FastFormat and trying to switch to fmt has resulted in a slowdown: writing 5.5GB of a CSV file in ~10 minutes instead of ~7.75 minutes overall.
I'm hoping a benchmark would be able to point out things to improve in fmt that would eventually let me switch to fmt and enjoy using a more future-proof library.
What would benchmarking against FastFormat require? I have access to Linux and Windows platforms, but not to a macOS platform.
Of course, it's entirely possible that I'm using the fmt API suboptimally.
What I've tried looks like:
ofs << fmt::format("{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}", 15 values) << endl;
to replace:
fastformat::writeln(ofs, value0, ",", value1, ",", ..., value14 );
I would like to contribute support for benchmarking against FastFormat.
Sure, PRs are welcome.
What would benchmarking against FastFormat require?
You'll need to implement FastFormat discovery in CMake, make it optional so that the benchmark continues to compile without this library installed and update relevant benchmarks such as src/int-benchmark.cc
.
ofs << fmt::format("{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}", ...) << endl;
is indeed suboptimal because it uses iostreams, flushes the stream and construct an unnecessary std::string
. I recommend doing
fmt::print("{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}\n", ...);
instead and using {fmt}'s master
which includes recent small format string optimizations.