blob: cba9c6a5ae20f023bd3afa8d2569edd23b811592 [file] [log] [blame]
// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include <base/basictypes.h>
#include <base/memory/scoped_ptr.h>
#include <metrics/metrics_library.h>
class MetricsStopwatch {
MetricsStopwatch(const char* name, int min, int max, int nbuckets);
void Start();
void Stop(); // and send measurement to UMA and reset
void StopIfStarted(); // and send measurement to UMA and reset
// In some situations, we can receive a report of the start time
// after the stop time. These report when both start and stop are
// known.
void SetStart(unsigned long long start);
void SetStop(unsigned long long stop);
void Reset(); // Only call this to abandon a measurement; Stop*()
// and Set*() already call this automatically.
static unsigned long long GetTimeMs(void);
void SetMetrics(MetricsLibraryInterface *m);
void ReportAndReset();
scoped_ptr<MetricsLibraryInterface> metrics_;
std::string name_;
int min_;
int max_;
int nbuckets_;
unsigned long long start_;
unsigned long long stop_;