mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-24 12:34:53 +08:00
updating the deps
This commit is contained in:
parent
5304b3d611
commit
c54e4a7aba
@ -3,7 +3,7 @@ include(FetchContent)
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
counters
|
counters
|
||||||
GIT_REPOSITORY https://github.com/lemire/counters.git
|
GIT_REPOSITORY https://github.com/lemire/counters.git
|
||||||
GIT_TAG v1.0.4
|
GIT_TAG v2.0.0
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(counters)
|
FetchContent_MakeAvailable(counters)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "counters/event_counter.h"
|
#include "counters/bench.h"
|
||||||
#include "fast_float/fast_float.h"
|
#include "fast_float/fast_float.h"
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -8,39 +8,14 @@
|
|||||||
#include <random>
|
#include <random>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <string>
|
#include <string>
|
||||||
event_collector collector;
|
|
||||||
|
|
||||||
template <class function_type>
|
|
||||||
event_aggregate bench(const function_type &function, size_t min_repeat = 10,
|
|
||||||
size_t min_time_ns = 1000000000,
|
|
||||||
size_t max_repeat = 1000000) {
|
|
||||||
event_aggregate aggregate{};
|
|
||||||
size_t N = min_repeat;
|
|
||||||
if (N == 0) {
|
|
||||||
N = 1;
|
|
||||||
}
|
|
||||||
for (size_t i = 0; i < N; i++) {
|
|
||||||
std::atomic_thread_fence(std::memory_order_acquire);
|
|
||||||
collector.start();
|
|
||||||
function();
|
|
||||||
std::atomic_thread_fence(std::memory_order_release);
|
|
||||||
event_count allocate_count = collector.end();
|
|
||||||
aggregate << allocate_count;
|
|
||||||
if ((i + 1 == N) && (aggregate.total_elapsed_ns() < min_time_ns) &&
|
|
||||||
(N < max_repeat)) {
|
|
||||||
N *= 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return aggregate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pretty_print(size_t volume, size_t bytes, std::string name,
|
void pretty_print(size_t volume, size_t bytes, std::string name,
|
||||||
event_aggregate agg) {
|
counters::event_aggregate agg) {
|
||||||
printf("%-40s : ", name.c_str());
|
printf("%-40s : ", name.c_str());
|
||||||
printf(" %5.2f GB/s ", bytes / agg.fastest_elapsed_ns());
|
printf(" %5.2f GB/s ", bytes / agg.fastest_elapsed_ns());
|
||||||
printf(" %5.1f Ma/s ", volume * 1000.0 / agg.fastest_elapsed_ns());
|
printf(" %5.1f Ma/s ", volume * 1000.0 / agg.fastest_elapsed_ns());
|
||||||
printf(" %5.2f ns/d ", agg.fastest_elapsed_ns() / volume);
|
printf(" %5.2f ns/d ", agg.fastest_elapsed_ns() / volume);
|
||||||
if (collector.has_events()) {
|
if (counters::event_collector().has_events()) {
|
||||||
printf(" %5.2f GHz ", agg.fastest_cycles() / agg.fastest_elapsed_ns());
|
printf(" %5.2f GHz ", agg.fastest_cycles() / agg.fastest_elapsed_ns());
|
||||||
printf(" %5.2f c/d ", agg.fastest_cycles() / volume);
|
printf(" %5.2f c/d ", agg.fastest_cycles() / volume);
|
||||||
printf(" %5.2f i/d ", agg.fastest_instructions() / volume);
|
printf(" %5.2f i/d ", agg.fastest_instructions() / volume);
|
||||||
@ -158,7 +133,7 @@ int main() {
|
|||||||
|
|
||||||
uint32_t sink = 0;
|
uint32_t sink = 0;
|
||||||
|
|
||||||
pretty_print(volume, bytes, "parse_ip_std_fromchars", bench([&]() {
|
pretty_print(volume, bytes, "parse_ip_std_fromchars", counters::bench([&]() {
|
||||||
const char *p = buf.data();
|
const char *p = buf.data();
|
||||||
const char *pend = buf.data() + bytes;
|
const char *pend = buf.data() + bytes;
|
||||||
uint32_t sum = 0;
|
uint32_t sum = 0;
|
||||||
@ -171,7 +146,7 @@ int main() {
|
|||||||
sink += sum;
|
sink += sum;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
pretty_print(volume, bytes, "parse_ip_fastfloat", bench([&]() {
|
pretty_print(volume, bytes, "parse_ip_fastfloat", counters::bench([&]() {
|
||||||
const char *p = buf.data();
|
const char *p = buf.data();
|
||||||
const char *pend = buf.data() + bytes;
|
const char *pend = buf.data() + bytes;
|
||||||
uint32_t sum = 0;
|
uint32_t sum = 0;
|
||||||
|
|||||||
@ -50,14 +50,14 @@ double findmax_fastfloat32(std::vector<std::basic_string<CharT>> &s) {
|
|||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_collector collector{};
|
counters::event_collector collector{};
|
||||||
|
|
||||||
#ifdef USING_COUNTERS
|
#ifdef USING_COUNTERS
|
||||||
template <class T, class CharT>
|
template <class T, class CharT>
|
||||||
std::vector<event_count>
|
std::vector<counters::event_count>
|
||||||
time_it_ns(std::vector<std::basic_string<CharT>> &lines, T const &function,
|
time_it_ns(std::vector<std::basic_string<CharT>> &lines, T const &function,
|
||||||
size_t repeat) {
|
size_t repeat) {
|
||||||
std::vector<event_count> aggregate;
|
std::vector<counters::event_count> aggregate;
|
||||||
bool printed_bug = false;
|
bool printed_bug = false;
|
||||||
for (size_t i = 0; i < repeat; i++) {
|
for (size_t i = 0; i < repeat; i++) {
|
||||||
collector.start();
|
collector.start();
|
||||||
@ -72,7 +72,7 @@ time_it_ns(std::vector<std::basic_string<CharT>> &lines, T const &function,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void pretty_print(double volume, size_t number_of_floats, std::string name,
|
void pretty_print(double volume, size_t number_of_floats, std::string name,
|
||||||
std::vector<event_count> events) {
|
std::vector<counters::event_count> events) {
|
||||||
double volumeMB = volume / (1024. * 1024.);
|
double volumeMB = volume / (1024. * 1024.);
|
||||||
double average_ns{0};
|
double average_ns{0};
|
||||||
double min_ns{DBL_MAX};
|
double min_ns{DBL_MAX};
|
||||||
@ -84,7 +84,7 @@ void pretty_print(double volume, size_t number_of_floats, std::string name,
|
|||||||
double branches_avg{0};
|
double branches_avg{0};
|
||||||
double branch_misses_min{0};
|
double branch_misses_min{0};
|
||||||
double branch_misses_avg{0};
|
double branch_misses_avg{0};
|
||||||
for (event_count e : events) {
|
for (counters::event_count e : events) {
|
||||||
double ns = e.elapsed_ns();
|
double ns = e.elapsed_ns();
|
||||||
average_ns += ns;
|
average_ns += ns;
|
||||||
min_ns = min_ns < ns ? min_ns : ns;
|
min_ns = min_ns < ns ? min_ns : ns;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user