#ifdef CATCH_CONFIG_ENABLE_BENCHMARKING #include #include #include #include std::string random_string(std::size_t length) { const std::string CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;\"'\n\t{}[]()"; std::random_device random_device; std::mt19937 generator(random_device()); std::uniform_int_distribution<> distribution(0, CHARACTERS.size() - 1); std::string random_string; for (std::size_t i = 0; i < length; ++i) { random_string += CHARACTERS[distribution(generator)]; } return random_string; } using namespace daggy; TEST_CASE("attempt output", "[serialize_attempt_performance][perf]") { size_t LOGSIZE = 512000; // Need lots of data AttemptRecord attempt{ .startTime = Clock::now(), .stopTime = Clock::now(), .rc = 0, .executorLog = random_string(LOGSIZE), .outputLog = random_string(LOGSIZE), .errorLog = random_string(LOGSIZE) }; BENCHMARK_ADVANCED("rj_dump")(Catch::Benchmark::Chronometer meter) { meter.measure([&] { return attemptRecordToJSON(attempt); }); }; } #endif