Repository: google/benchmark
File: include/benchmark/benchmark.h (C/C++)

Code before:
  bool first_report_;
};

class BENCHMARK_DEPRECATED_MSG("The CSV Reporter will be removed in a future release")
      CSVReporter : public BenchmarkReporter {
 public:
  CSVReporter() : printed_header_(false) {}
  virtual bool ReportContext(const Context& context);
  virtual void ReportRuns(const std::vector<Run>& reports);

 private:
  void PrintRunData(const Run& report);

  bool printed_header_;
  std::set<std::string> user_counter_names_;
};

// If a MemoryManager is registered, it can be used to report memory statistics
// for a run of the benchmark.
class MemoryManager {
 public:
  struct Result {
    explicit Result(int64_t iters)
        : num_allocs(0), max_bytes_used(0), iterations(iters) {}
    int64_t num_allocs;
    int64_t max_bytes_used;
    const int64_t iterations;
  };

  // Implement this to start recording allocation information.
  virtual void Start() = 0;

  // Implement this to stop recording and fill out the given Result structure.
  virtual void Stop(Result* result) = 0;
};

inline const char* GetTimeUnitString(TimeUnit unit) {
  switch (unit) {
    case kMillisecond:
      return "ms";
    case kMicrosecond:
      return "us";
    case kNanosecond:
    default:
      return "ns";
  }
}

inline double GetTimeUnitMultiplier(TimeUnit unit) {
  switch (unit) {
    case kMillisecond:

Review comment (suggestion):
It would be great to have a comment explaining _what_ this is.
Is this the total amount of memory allocated, ever, or the peak memory usage?

For reference, it is possible to get the former natively - e.g. [`llvm::sys::Process::GetMallocUsage()`](https://github.com/llvm-mirror/llvm/blob/09f0f7ccc5eec100c3902c070f674a5c97a17c92/lib/Support/Unix/Process.inc#L87-L114)

Code after:
 protected:
  virtual void PrintRunData(const Run& report);
  virtual void PrintHeader(const Run& report);

  OutputOptions output_options_;
  size_t name_field_width_;
  UserCounters prev_counters_;
  bool printed_header_;
};

class JSONReporter : public BenchmarkReporter {
 public:
  JSONReporter() : first_report_(true) {}
  virtual bool ReportContext(const Context& context);
  virtual void ReportRuns(const std::vector<Run>& reports);
  virtual void Finalize();

 private:
  void PrintRunData(const Run& report);

  bool first_report_;
};

class BENCHMARK_DEPRECATED_MSG("The CSV Reporter will be removed in a future release")
      CSVReporter : public BenchmarkReporter {
 public:
  CSVReporter() : printed_header_(false) {}
  virtual bool ReportContext(const Context& context);
  virtual void ReportRuns(const std::vector<Run>& reports);

 private:
  void PrintRunData(const Run& report);

  bool printed_header_;
  std::set<std::string> user_counter_names_;
};

// If a MemoryManager is registered, it can be used to collect and report
// allocation metrics for a run of the benchmark.
class MemoryManager {
 public:
  struct Result {
    Result() : num_allocs(0), max_bytes_used(0) {}

    // The number of allocations made in total between Start and Stop.
    int64_t num_allocs;

    // The peak memory use between Start and Stop.
    int64_t max_bytes_used;
  };