Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Unified Diff: media/base/scoped_uma_timer.h

Issue 14827002: Report timing statistics for audio controller methods via UMA. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_output_controller.cc ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/scoped_uma_timer.h
diff --git a/media/base/scoped_uma_timer.h b/media/base/scoped_uma_timer.h
new file mode 100644
index 0000000000000000000000000000000000000000..d701ada84b38b2e4e822fd2ddcbd8c0dc133858d
--- /dev/null
+++ b/media/base/scoped_uma_timer.h
@@ -0,0 +1,24 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_SCOPED_UMA_TIMER_H_
+#define MEDIA_BASE_SCOPED_UMA_TIMER_H_
+
+#include "base/metrics/histogram.h"
+#include "base/time.h"
+
+// Scoped class which logs its time on this earth as a UMA statistic. Must be
+// a #define macro since UMA macros prevent variables as names.
+#define SCOPED_UMA_HISTOGRAM_TIMER(name) \
+ class ScopedHistogramTimer { \
jar (doing other things) 2013/05/03 21:50:26 Since you messed with __LINE__ on line 22 so that
DaleCurtis 2013/05/03 23:16:57 Ah, right. Actually none of this works at all. I
jar (doing other things) 2013/05/04 08:58:31 <Doh>... I feel embarrassed.. I used to be a real
DaleCurtis 2013/05/07 20:08:51 Done.
+ public: \
+ ScopedHistogramTimer() : constructed_(base::Time::Now()) {} \
jar (doing other things) 2013/05/03 21:50:26 You should use TimeTicks, as it is guaranteed mono
DaleCurtis 2013/05/03 23:16:57 TimeTicks is a kind of expensive per the comment i
jar (doing other things) 2013/05/04 08:58:31 Definately use TimeTicks, not Time Performance is
DaleCurtis 2013/05/07 20:08:51 Done.
+ ~ScopedHistogramTimer() { \
+ UMA_HISTOGRAM_TIMES(name, base::Time::Now() - constructed_); \
+ } \
+ private: \
+ base::Time constructed_; \
jar (doing other things) 2013/05/03 21:50:26 nit: You probably should have NO_DEFAULT_COPY_OR_A
DaleCurtis 2013/05/03 23:16:57 Done.
DaleCurtis 2013/05/08 00:01:30 Actually removed in the latest patch set. VC++ wo
jar (doing other things) 2013/05/08 00:55:23 If you're interested, the following should work (i
DaleCurtis 2013/05/08 01:34:04 Sorry for the confusion, my above comment about VC
+ } scoped_uma_timer##__LINE__
+
+#endif // MEDIA_BASE_SCOPED_UMA_TIMER_H_
« no previous file with comments | « media/audio/audio_output_controller.cc ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698