MCPcopy Create free account
hub / github.com/ashvardanian/less_slow.cpp / logging

Function logging

less_slow.cpp:6362–6383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6360
6361template <typename logger_type_>
6362static void logging(bm::State &state) {
6363 struct {
6364 int code;
6365 std::string_view message;
6366 } errors[3] = {
6367 {1, "Operation not permitted"sv},
6368 {12, "Cannot allocate memory"sv},
6369 {113, "No route to host"sv},
6370 };
6371 char buffer[1024];
6372 logger_type_ logger;
6373 std::size_t iteration_index = 0;
6374 std::size_t bytes_logged = 0;
6375 for (auto _ : state) {
6376 bytes_logged += logger( //
6377 buffer, sizeof(buffer), //
6378 std::source_location::current(), //
6379 errors[iteration_index % 3].code, errors[iteration_index % 3].message);
6380 iteration_index++;
6381 }
6382 state.SetBytesProcessed(bytes_logged);
6383}
6384
6385struct log_printf_t {
6386 std::size_t operator()( //

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected