/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include #include using namespace std::chrono; std::vector Benchmark::MetricsEmitter::CreateMetricsForOp(const std::string &metricName, const std::vector &dimensions, const std::function &op) const { std::vector metrics; auto before = steady_clock::now(); auto success = op(); auto after = steady_clock::now(); auto duration = duration_cast(after - before); if (success) { metrics.push_back({metricName, SUCCESS, dimensions, "true"}); } else { metrics.push_back({metricName, SUCCESS, dimensions, "false"}); } metrics.push_back({metricName, DURATION, dimensions, std::to_string(duration.count())}); return metrics; }