88 */
99
1010#include " algorithms.h"
11+ #include < vector>
1112#define IEEE_8087
1213#include " benchutil.h"
1314#include " cxxopts.hpp"
@@ -83,9 +84,35 @@ void evaluateProperties(const std::vector<T> &lines,
8384 }
8485}
8586
87+ struct diy_float_t {
88+ uint64_t significand;
89+ int exponent;
90+ bool is_negative;
91+ };
92+
8693template <arithmetic_float T>
8794void process (const std::vector<T> &lines,
8895 const std::array<BenchArgs<T>, Benchmarks::COUNT> &args, const std::span<std::string> filter = {}) {
96+ // We have a special algorithm for the reference:
97+ std::string just_string = " just_string" ;
98+ if (is_matched (just_string, filter)) {
99+ std::vector<diy_float_t > parsed;
100+ for (auto d : lines) {
101+ auto v = jkj::grisu_exact (d);
102+ parsed.emplace_back (v.significand , v.exponent , v.is_negative );
103+ }
104+ pretty_print (parsed, just_string, [](const std::vector<diy_float_t >& parsed) -> int {
105+ int volume = 0 ;
106+ char buf[100 ];
107+ std::span<char > bufspan (buf, sizeof (buf));
108+ for (const auto v : parsed)
109+ volume += to_chars (v.significand , v.exponent , v.is_negative , bufspan.data ());
110+ return volume;
111+ }, 100 );
112+ } else {
113+ std::cout << " # skipping " << just_string << std::endl;
114+
115+ }
89116 for (const auto &algo : args) {
90117 if (!algo.used ) {
91118 std::cout << " # skipping " << algo.name << std::endl;
@@ -105,6 +132,7 @@ void process(const std::vector<T> &lines,
105132 return volume;
106133 }, algo.testRepeat );
107134 }
135+
108136}
109137
110138template <typename T>
0 commit comments