OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_BASE_SCOPED_UMA_TIMER_H_ | |
6 #define MEDIA_BASE_SCOPED_UMA_TIMER_H_ | |
7 | |
8 #include "base/metrics/histogram.h" | |
9 #include "base/time.h" | |
10 | |
11 // Scoped class which logs its time on this earth as a UMA statistic. Must be | |
12 // a #define macro since UMA macros prevent variables as names. | |
13 #define SCOPED_UMA_HISTOGRAM_TIMER(name) \ | |
14 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.
| |
15 public: \ | |
16 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.
| |
17 ~ScopedHistogramTimer() { \ | |
18 UMA_HISTOGRAM_TIMES(name, base::Time::Now() - constructed_); \ | |
19 } \ | |
20 private: \ | |
21 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
| |
22 } scoped_uma_timer##__LINE__ | |
23 | |
24 #endif // MEDIA_BASE_SCOPED_UMA_TIMER_H_ | |
OLD | NEW |