Use new double differ in kostya/large_random benchmarks
This commit is contained in:
parent
b61f2799a8
commit
6367e55a5f
|
@ -34,7 +34,7 @@ struct runner : public json_benchmark::file_runner<I> {
|
|||
|
||||
template<typename R>
|
||||
bool diff(benchmark::State &state, runner<R> &reference) {
|
||||
return diff_results(state, result, reference.result);
|
||||
return json_benchmark::diff_results(state, result, reference.result);
|
||||
}
|
||||
|
||||
size_t items_per_iteration() {
|
||||
|
|
|
@ -25,7 +25,7 @@ struct runner : public json_benchmark::file_runner<I> {
|
|||
|
||||
template<typename R>
|
||||
bool diff(benchmark::State &state, runner<R> &reference) {
|
||||
return diff_results(state, result, reference.result);
|
||||
return json_benchmark::diff_results(state, result, reference.result);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <sstream>
|
||||
#include <limits>
|
||||
|
||||
namespace json_benchmark {
|
||||
|
||||
template<typename T>
|
||||
static bool diff_results(benchmark::State &state, const T &result, const T &reference);
|
||||
|
||||
|
@ -25,12 +27,11 @@ bool result_differ<double>::diff(benchmark::State &state, const double &result,
|
|||
if (result != reference) {
|
||||
std::stringstream str;
|
||||
// We print it out using full precision.
|
||||
auto prior_precision = str.precision(std::numeric_limits<double>::max_digits10);
|
||||
str << "result incorrect: " << result << " ... reference: " << reference;
|
||||
str.precision(prior_precision); // reset to prior state
|
||||
str << std::hexfloat; // If there are floats, we want to see them in hexadecimal form!
|
||||
str << "result incorrect (hexadecimal notation): " << result << " ... reference: " << reference;
|
||||
str << std::defaultfloat; // reset to prior state
|
||||
constexpr auto precision = std::numeric_limits<double>::max_digits10;
|
||||
str << std::setprecision(precision);
|
||||
str << "incorrect double result: " << std::endl;
|
||||
str << " result: " << std::left << std::setw(precision+2) << result << " (hexfloat " << std::hexfloat << result << ")" << std::defaultfloat << std::endl;
|
||||
str << "reference: " << std::left << std::setw(precision+2) << reference << " (hexfloat " << std::hexfloat << reference << ")" << std::defaultfloat << std::endl;
|
||||
state.SkipWithError(str.str().data());
|
||||
return false;
|
||||
}
|
||||
|
@ -68,3 +69,4 @@ static bool diff_results(benchmark::State &state, const T &result, const T &refe
|
|||
return result_differ<T>::diff(state, result, reference);
|
||||
}
|
||||
|
||||
} // namespace json_benchmark
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
|
||||
#include "json_benchmark/string_runner.h"
|
||||
#include <vector>
|
||||
#include <random>
|
||||
|
@ -14,12 +12,6 @@ struct point {
|
|||
double x;
|
||||
double y;
|
||||
double z;
|
||||
simdjson_really_inline bool operator==(const point &other) const {
|
||||
return x == other.x && y == other.y && z == other.z;
|
||||
}
|
||||
simdjson_really_inline bool operator!=(const point &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
simdjson_unused static std::ostream &operator<<(std::ostream &o, const point &p) {
|
||||
|
@ -44,7 +36,7 @@ struct runner : public json_benchmark::string_runner<I> {
|
|||
|
||||
template<typename R>
|
||||
bool diff(benchmark::State &state, runner<R> &reference) {
|
||||
return diff_results(state, result, reference.result);
|
||||
return json_benchmark::diff_results(state, result, reference.result);
|
||||
}
|
||||
|
||||
size_t items_per_iteration() {
|
||||
|
@ -100,4 +92,11 @@ template<typename I> simdjson_really_inline static void kostya(benchmark::State
|
|||
|
||||
} // namespace kostya
|
||||
|
||||
#endif // SIMDJSON_EXCEPTIONS
|
||||
namespace json_benchmark {
|
||||
template<>
|
||||
bool result_differ<kostya::point>::diff(benchmark::State &state, const kostya::point &result, const kostya::point &reference) {
|
||||
return diff_results(state, result.x, reference.x)
|
||||
&& diff_results(state, result.y, reference.y)
|
||||
&& diff_results(state, result.z, reference.z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,6 @@ struct point {
|
|||
double x;
|
||||
double y;
|
||||
double z;
|
||||
simdjson_really_inline bool operator==(const point &other) const {
|
||||
return x == other.x && y == other.y && z == other.z;
|
||||
}
|
||||
simdjson_really_inline bool operator!=(const point &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
simdjson_unused static std::ostream &operator<<(std::ostream &o, const point &p) {
|
||||
|
@ -41,7 +35,7 @@ struct runner : public json_benchmark::string_runner<I> {
|
|||
|
||||
template<typename R>
|
||||
bool diff(benchmark::State &state, runner<R> &reference) {
|
||||
return diff_results(state, result, reference.result);
|
||||
return json_benchmark::diff_results(state, result, reference.result);
|
||||
}
|
||||
|
||||
size_t items_per_iteration() {
|
||||
|
@ -80,3 +74,12 @@ template<typename T> static void large_random(benchmark::State &state) {
|
|||
}
|
||||
|
||||
} // namespace large_random
|
||||
|
||||
namespace json_benchmark {
|
||||
template<>
|
||||
bool result_differ<large_random::point>::diff(benchmark::State &state, const large_random::point &result, const large_random::point &reference) {
|
||||
return diff_results(state, result.x, reference.x)
|
||||
&& diff_results(state, result.y, reference.y)
|
||||
&& diff_results(state, result.z, reference.z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ struct runner : public json_benchmark::file_runner<I> {
|
|||
|
||||
template<typename R>
|
||||
bool diff(benchmark::State &state, runner<R> &reference) {
|
||||
return diff_results(state, result, reference.result);
|
||||
return json_benchmark::diff_results(state, result, reference.result);
|
||||
}
|
||||
|
||||
size_t items_per_iteration() {
|
||||
|
|
Loading…
Reference in New Issue