50#ifndef CA_BENCH_SUPPORT_H
51#define CA_BENCH_SUPPORT_H
84#elif defined(__GNUC__)
85 return std::string(
"gcc ") + std::to_string(
__GNUC__) +
'.'
102 std::string
model =
"unknown";
103 std::ifstream
cpuinfo(
"/proc/cpuinfo");
105 while (std::getline(
cpuinfo, line))
106 if (line.rfind(
"model name", 0) == 0)
108 const std::size_t
colon = line.find(
':');
113 for (
char &c :
model)
114 if (c ==
'"' or c ==
',' or c ==
'\\')
130 if (
const char *
env = std::getenv(
"CA_BENCH_REPEATS"))
132 const long parsed = std::strtol(
env,
nullptr, 10);
134 return static_cast<std::size_t
>(
parsed);
155template <
typename Work>
161 using clock = std::chrono::steady_clock;
167 std::vector<std::uint64_t> samples;
169 for (std::size_t i = 0; i <
repeats; ++i)
171 const auto start = clock::now();
173 const auto elapsed = clock::now() - start;
174 samples.push_back(
static_cast<std::uint64_t
>(
175 std::chrono::duration_cast<std::chrono::nanoseconds>(elapsed).
count()));
178 std::sort(samples.begin(), samples.end());
179 const std::uint64_t
median = samples[samples.size() / 2];
182 result.
name = std::move(name);
203 out <<
"{\"name\":\"" << result.
name <<
"\","
204 <<
"\"wall_ns\":" << result.
wall_ns <<
','
207 <<
"\"cpu\":\"" <<
cpu_string() <<
"\"}" << std::endl;
size_t size_t int32_t * out
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
std::size_t resolve_repeats(const std::size_t fallback)
Resolve the number of timed repetitions for one anchor.
void emit_json(const Bench_Result &result, std::ostream &out=std::cout)
Print one benchmark result as a single structured JSON object.
std::string cpu_string()
Read the CPU model name advertised by the host.
Bench_Result measure(std::string name, const double processed_cells, std::size_t repeats, Work &&work)
Time a kernel with one warmup pass plus a median of timed passes.
std::string compiler_string()
Describe the compiler that produced the running binary.
Main namespace for Aleph-w library functions.
const T * median(const T &a, const T &b, const T &c, const Compare &cmp=Compare())
Return a pointer to the median value among three elements.
and
Check uniqueness with explicit hash + equality functors.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Outcome of one measured anchor benchmark.
std::string name
stable benchmark identifier.
double cells_per_sec
processed cells divided by the median run time.
std::uint64_t wall_ns
median wall-clock time of one run, nanoseconds.