Print the history benchmark's results with a stream

Flawfinder flagged the printf in history.cpp (CWE-134), although its format string is a constant. The stream prints the
same text, so history.py reads it as before.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-11-04 05:35:16 +01:00
1 parent 247b3cd5bf
commit a6650e75f1
1 file changed
+3 -2
+3 -2
View File
@@ -17,9 +17,10 @@
#endif
#include <algorithm>
#include <chrono>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
@@ -64,7 +65,7 @@ static void bench(const char* name, const std::function<std::size_t()>& f)
v.push_back(std::chrono::duration<double, std::micro>(clk::now() - t0).count() / n);
}
std::sort(v.begin(), v.end());
std::printf("%s %.3f\n", name, v[4]);
std::cout << name << ' ' << std::fixed << std::setprecision(3) << v[4] << '\n';
}
int main(int, char** argv)