14242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// Copyright 2015 Google Inc. All rights reserved. 24242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// 34242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// Licensed under the Apache License, Version 2.0 (the "License"); 44242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// you may not use this file except in compliance with the License. 54242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// You may obtain a copy of the License at 64242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// 74242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// http://www.apache.org/licenses/LICENSE-2.0 84242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// 94242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// Unless required by applicable law or agreed to in writing, software 104242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// distributed under the License is distributed on an "AS IS" BASIS, 114242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// See the License for the specific language governing permissions and 134242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// limitations under the License. 144242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier#ifndef BENCHMARK_REPORTER_H_ 154242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier#define BENCHMARK_REPORTER_H_ 164242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 175686bf1b38f8aa713267097d7c1944140f71b5d3Eric#include <cassert> 185686bf1b38f8aa713267097d7c1944140f71b5d3Eric#include <iosfwd> 194242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier#include <string> 204242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier#include <utility> 214242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier#include <vector> 22a9a66c85bbfda1d744c267c5e5aa073ef3d1c1d5jpmag#include <set> 234242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 2422cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael#include "benchmark_api.h" // For forward declaration of BenchmarkReporter 25df904a1980b148139e566028dad27e3bea828afdEric Fiselier 264242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiseliernamespace benchmark { 274242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 284242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// Interface for custom benchmark result printers. 294242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// By default, benchmark reports are printed to stdout. However an application 304242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// can control the destination of the reports by calling 314242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// RunSpecifiedBenchmarks and passing it a custom reporter object. 324242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// The reporter object must implement the following interface. 334242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselierclass BenchmarkReporter { 344242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier public: 354242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier struct Context { 364242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier int num_cpus; 374242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier double mhz_per_cpu; 384242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier bool cpu_scaling_enabled; 394242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 404242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier // The number of chars in the longest benchmark name. 414242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier size_t name_field_width; 424242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier }; 434242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 444242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier struct Run { 45332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon Run() 46332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon : error_occurred(false), 47332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon iterations(1), 48332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon time_unit(kNanosecond), 49332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon real_accumulated_time(0), 50332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon cpu_accumulated_time(0), 51332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon bytes_per_second(0), 52332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon items_per_second(0), 53332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon max_heapbytes_used(0), 54332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon complexity(oNone), 55332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon complexity_lambda(), 56332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon complexity_n(0), 57332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon report_big_o(false), 58a9a66c85bbfda1d744c267c5e5aa073ef3d1c1d5jpmag report_rms(false), 59a9a66c85bbfda1d744c267c5e5aa073ef3d1c1d5jpmag counters() {} 604242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 614242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier std::string benchmark_name; 624242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier std::string report_label; // Empty if not set by benchmark. 6343017f8b1510a50855e6b0ea145a534d3d754068Eric Fiselier bool error_occurred; 6443017f8b1510a50855e6b0ea145a534d3d754068Eric Fiselier std::string error_message; 6543017f8b1510a50855e6b0ea145a534d3d754068Eric Fiselier 662cf277b6f65d882cc8d3010fc1c91deb5edb32baJean-Louis Leroy int64_t iterations; 677c69b36078b5773fbd6b09b539a30400138607a7Kai Wolf TimeUnit time_unit; 684242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier double real_accumulated_time; 694242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier double cpu_accumulated_time; 704242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 711b263fe6d906bb0854b84247f1b395bbacd3b88eEric // Return a value representing the real time per iteration in the unit 721b263fe6d906bb0854b84247f1b395bbacd3b88eEric // specified by 'time_unit'. 731b263fe6d906bb0854b84247f1b395bbacd3b88eEric // NOTE: If 'iterations' is zero the returned value represents the 741b263fe6d906bb0854b84247f1b395bbacd3b88eEric // accumulated time. 751b263fe6d906bb0854b84247f1b395bbacd3b88eEric double GetAdjustedRealTime() const; 761b263fe6d906bb0854b84247f1b395bbacd3b88eEric 771b263fe6d906bb0854b84247f1b395bbacd3b88eEric // Return a value representing the cpu time per iteration in the unit 781b263fe6d906bb0854b84247f1b395bbacd3b88eEric // specified by 'time_unit'. 791b263fe6d906bb0854b84247f1b395bbacd3b88eEric // NOTE: If 'iterations' is zero the returned value represents the 801b263fe6d906bb0854b84247f1b395bbacd3b88eEric // accumulated time. 811b263fe6d906bb0854b84247f1b395bbacd3b88eEric double GetAdjustedCPUTime() const; 821b263fe6d906bb0854b84247f1b395bbacd3b88eEric 834242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier // Zero if not set by benchmark. 844242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier double bytes_per_second; 854242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier double items_per_second; 864242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 874242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier // This is set to 0.0 if memory tracing is not enabled. 884242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier double max_heapbytes_used; 8911e304355492670709c60e6d39eb42fc01fd878aIsmael 90b73dc22944cb933289bbdbf5bb6616dbfc50168fIsmael // Keep track of arguments to compute asymptotic complexity 91867f9145a0a45f8b993cec8b48309c19391acaa0Ismael BigO complexity; 92867f9145a0a45f8b993cec8b48309c19391acaa0Ismael BigOFunc* complexity_lambda; 932859ae93949a7a3415082e65001f25e8e5e78284Ismael int complexity_n; 9411e304355492670709c60e6d39eb42fc01fd878aIsmael 95290bd60289ef571875415cf82be805f9a446c6a9Ismael // Inform print function whether the current run is a complexity report 965f9823bd92b2a24da06fac7b43f6658ec20cc901Ismael bool report_big_o; 972e5c397b4829503a5cb023ac67d2a1f13ebda3aaIsmael bool report_rms; 98a9a66c85bbfda1d744c267c5e5aa073ef3d1c1d5jpmag 999e3465560240ffb242b50a47cb7f19251a12ee42jpmag UserCounters counters; 1004242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier }; 1014242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 1025686bf1b38f8aa713267097d7c1944140f71b5d3Eric // Construct a BenchmarkReporter with the output stream set to 'std::cout' 1035686bf1b38f8aa713267097d7c1944140f71b5d3Eric // and the error stream set to 'std::cerr' 1045686bf1b38f8aa713267097d7c1944140f71b5d3Eric BenchmarkReporter(); 1055686bf1b38f8aa713267097d7c1944140f71b5d3Eric 1064242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier // Called once for every suite of benchmarks run. 1074242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier // The parameter "context" contains information that the 1084242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier // reporter may wish to use when generating its report, for example the 1094242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier // platform under which the benchmarks are running. The benchmark run is 1104242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier // never started if this function returns false, allowing the reporter 1114242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier // to skip runs based on the context information. 11220f1c0e2a8e692076dd7a5586f73ab8e2d726c12Eric Fiselier virtual bool ReportContext(const Context& context) = 0; 1134242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 1144242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier // Called once for each group of benchmark runs, gives information about 1151b263fe6d906bb0854b84247f1b395bbacd3b88eEric // cpu-time and heap memory usage during the benchmark run. If the group 1161b263fe6d906bb0854b84247f1b395bbacd3b88eEric // of runs contained more than two entries then 'report' contains additional 1171b263fe6d906bb0854b84247f1b395bbacd3b88eEric // elements representing the mean and standard deviation of those runs. 1181b263fe6d906bb0854b84247f1b395bbacd3b88eEric // Additionally if this group of runs was the last in a family of benchmarks 1191b263fe6d906bb0854b84247f1b395bbacd3b88eEric // 'reports' contains additional entries representing the asymptotic 1201b263fe6d906bb0854b84247f1b395bbacd3b88eEric // complexity and RMS of that benchmark family. 12120f1c0e2a8e692076dd7a5586f73ab8e2d726c12Eric Fiselier virtual void ReportRuns(const std::vector<Run>& report) = 0; 12211e304355492670709c60e6d39eb42fc01fd878aIsmael 12320f1c0e2a8e692076dd7a5586f73ab8e2d726c12Eric Fiselier // Called once and only once after ever group of benchmarks is run and 12420f1c0e2a8e692076dd7a5586f73ab8e2d726c12Eric Fiselier // reported. 1251b263fe6d906bb0854b84247f1b395bbacd3b88eEric virtual void Finalize() {} 1264242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 1275686bf1b38f8aa713267097d7c1944140f71b5d3Eric // REQUIRES: The object referenced by 'out' is valid for the lifetime 1285686bf1b38f8aa713267097d7c1944140f71b5d3Eric // of the reporter. 1295686bf1b38f8aa713267097d7c1944140f71b5d3Eric void SetOutputStream(std::ostream* out) { 1305686bf1b38f8aa713267097d7c1944140f71b5d3Eric assert(out); 1315686bf1b38f8aa713267097d7c1944140f71b5d3Eric output_stream_ = out; 1325686bf1b38f8aa713267097d7c1944140f71b5d3Eric } 1335686bf1b38f8aa713267097d7c1944140f71b5d3Eric 1345686bf1b38f8aa713267097d7c1944140f71b5d3Eric // REQUIRES: The object referenced by 'err' is valid for the lifetime 1355686bf1b38f8aa713267097d7c1944140f71b5d3Eric // of the reporter. 1365686bf1b38f8aa713267097d7c1944140f71b5d3Eric void SetErrorStream(std::ostream* err) { 1375686bf1b38f8aa713267097d7c1944140f71b5d3Eric assert(err); 1385686bf1b38f8aa713267097d7c1944140f71b5d3Eric error_stream_ = err; 1395686bf1b38f8aa713267097d7c1944140f71b5d3Eric } 1405686bf1b38f8aa713267097d7c1944140f71b5d3Eric 141332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon std::ostream& GetOutputStream() const { return *output_stream_; } 1425686bf1b38f8aa713267097d7c1944140f71b5d3Eric 143332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon std::ostream& GetErrorStream() const { return *error_stream_; } 1442859ae93949a7a3415082e65001f25e8e5e78284Ismael 1454242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier virtual ~BenchmarkReporter(); 1461b263fe6d906bb0854b84247f1b395bbacd3b88eEric 1471b263fe6d906bb0854b84247f1b395bbacd3b88eEric // Write a human readable string to 'out' representing the specified 1481b263fe6d906bb0854b84247f1b395bbacd3b88eEric // 'context'. 1491b263fe6d906bb0854b84247f1b395bbacd3b88eEric // REQUIRES: 'out' is non-null. 1501b263fe6d906bb0854b84247f1b395bbacd3b88eEric static void PrintBasicContext(std::ostream* out, Context const& context); 1515686bf1b38f8aa713267097d7c1944140f71b5d3Eric 15222cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael private: 1535686bf1b38f8aa713267097d7c1944140f71b5d3Eric std::ostream* output_stream_; 1545686bf1b38f8aa713267097d7c1944140f71b5d3Eric std::ostream* error_stream_; 1554242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier}; 1564242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 1574242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// Simple reporter that outputs benchmark data to the console. This is the 1584242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier// default reporter used by RunSpecifiedBenchmarks(). 1594242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselierclass ConsoleReporter : public BenchmarkReporter { 1600de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaespublic: 1610de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes enum OutputOptions { 1620de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes OO_None = 0, 1630de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes OO_Color = 1, 1640de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes OO_Tabular = 2, 1650de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes OO_ColorTabular = OO_Color|OO_Tabular, 1660de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes OO_Defaults = OO_ColorTabular 1670de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes }; 1680de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes explicit ConsoleReporter(OutputOptions opts_ = OO_Defaults) 1690de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes : output_options_(opts_), name_field_width_(0), 1700de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes prev_counters_(), printed_header_(false) {} 17144128d87d2846fc20d540ef41eda6da9ffbb6abaEric Fiselier 17220f1c0e2a8e692076dd7a5586f73ab8e2d726c12Eric Fiselier virtual bool ReportContext(const Context& context); 17320f1c0e2a8e692076dd7a5586f73ab8e2d726c12Eric Fiselier virtual void ReportRuns(const std::vector<Run>& reports); 1747c69b36078b5773fbd6b09b539a30400138607a7Kai Wolf 175332f677b8bec401641a2743ab5d741c13cc6811dDominic Hamon protected: 17620f1c0e2a8e692076dd7a5586f73ab8e2d726c12Eric Fiselier virtual void PrintRunData(const Run& report); 177a9a66c85bbfda1d744c267c5e5aa073ef3d1c1d5jpmag virtual void PrintHeader(const Run& report); 178a9a66c85bbfda1d744c267c5e5aa073ef3d1c1d5jpmag 1790de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes OutputOptions output_options_; 18020f1c0e2a8e692076dd7a5586f73ab8e2d726c12Eric Fiselier size_t name_field_width_; 1810de985ae9d4ea1582125a5414a99ca90c368ca10Joao Paulo Magalhaes UserCounters prev_counters_; 182a9a66c85bbfda1d744c267c5e5aa073ef3d1c1d5jpmag bool printed_header_; 1834242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier}; 1844242f2f1d73d7800d95cfc2af0f3a3513dad2dc5Eric Fiselier 185f65da9d58165c6ab626d6a55b9d47968510c72aeEric Fiselierclass JSONReporter : public BenchmarkReporter { 18622cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael public: 187f65da9d58165c6ab626d6a55b9d47968510c72aeEric Fiselier JSONReporter() : first_report_(true) {} 188f65da9d58165c6ab626d6a55b9d47968510c72aeEric Fiselier virtual bool ReportContext(const Context& context); 189f65da9d58165c6ab626d6a55b9d47968510c72aeEric Fiselier virtual void ReportRuns(const std::vector<Run>& reports); 190f65da9d58165c6ab626d6a55b9d47968510c72aeEric Fiselier virtual void Finalize(); 191f65da9d58165c6ab626d6a55b9d47968510c72aeEric Fiselier 19222cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael private: 193f65da9d58165c6ab626d6a55b9d47968510c72aeEric Fiselier void PrintRunData(const Run& report); 194f65da9d58165c6ab626d6a55b9d47968510c72aeEric Fiselier 195f65da9d58165c6ab626d6a55b9d47968510c72aeEric Fiselier bool first_report_; 196f65da9d58165c6ab626d6a55b9d47968510c72aeEric Fiselier}; 197f65da9d58165c6ab626d6a55b9d47968510c72aeEric Fiselier 19871c41cde57d7c741fca05b07585966129cf2ac5bDominic Hamonclass CSVReporter : public BenchmarkReporter { 19922cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael public: 200a9a66c85bbfda1d744c267c5e5aa073ef3d1c1d5jpmag CSVReporter() : printed_header_(false) {} 20171c41cde57d7c741fca05b07585966129cf2ac5bDominic Hamon virtual bool ReportContext(const Context& context); 20271c41cde57d7c741fca05b07585966129cf2ac5bDominic Hamon virtual void ReportRuns(const std::vector<Run>& reports); 20371c41cde57d7c741fca05b07585966129cf2ac5bDominic Hamon 20422cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael private: 20571c41cde57d7c741fca05b07585966129cf2ac5bDominic Hamon void PrintRunData(const Run& report); 206a9a66c85bbfda1d744c267c5e5aa073ef3d1c1d5jpmag 207a9a66c85bbfda1d744c267c5e5aa073ef3d1c1d5jpmag bool printed_header_; 208a9a66c85bbfda1d744c267c5e5aa073ef3d1c1d5jpmag std::set< std::string > user_counter_names_; 20971c41cde57d7c741fca05b07585966129cf2ac5bDominic Hamon}; 21071c41cde57d7c741fca05b07585966129cf2ac5bDominic Hamon 21102230445e065456371cea2a18d5fee6a33b0c1d9Eric Fiselierinline const char* GetTimeUnitString(TimeUnit unit) { 21202230445e065456371cea2a18d5fee6a33b0c1d9Eric Fiselier switch (unit) { 21322cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael case kMillisecond: 21422cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael return "ms"; 21522cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael case kMicrosecond: 21622cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael return "us"; 21722cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael case kNanosecond: 21822cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael default: 21922cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael return "ns"; 22002230445e065456371cea2a18d5fee6a33b0c1d9Eric Fiselier } 22102230445e065456371cea2a18d5fee6a33b0c1d9Eric Fiselier} 22202230445e065456371cea2a18d5fee6a33b0c1d9Eric Fiselier 22302230445e065456371cea2a18d5fee6a33b0c1d9Eric Fiselierinline double GetTimeUnitMultiplier(TimeUnit unit) { 224867f9145a0a45f8b993cec8b48309c19391acaa0Ismael switch (unit) { 22522cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael case kMillisecond: 22622cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael return 1e3; 22722cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael case kMicrosecond: 22822cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael return 1e6; 22922cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael case kNanosecond: 23022cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael default: 23122cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael return 1e9; 23202230445e065456371cea2a18d5fee6a33b0c1d9Eric Fiselier } 23302230445e065456371cea2a18d5fee6a33b0c1d9Eric Fiselier} 23402230445e065456371cea2a18d5fee6a33b0c1d9Eric Fiselier 23522cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael} // end namespace benchmark 23622cb9d9ce0ff12219f5ca6c4a28124d11730e66fIsmael#endif // BENCHMARK_REPORTER_H_ 237