Rescale histogram timers.

R=vogelheim@chromium.org

Review URL: https://codereview.chromium.org/875873002

Cr-Commit-Position: refs/heads/master@{#26295}
This commit is contained in:
yangguo 2015-01-27 06:08:15 -08:00 committed by Commit bot
parent 59a02ebdbe
commit 22421bbe9f
3 changed files with 49 additions and 40 deletions

View File

@ -47,8 +47,11 @@ void HistogramTimer::Start() {
// Stop the timer and record the results.
void HistogramTimer::Stop() {
if (Enabled()) {
// Compute the delta between start and stop, in milliseconds.
AddSample(static_cast<int>(timer_.Elapsed().InMilliseconds()));
int64_t sample = resolution_ == MICROSECOND
? timer_.Elapsed().InMicroseconds()
: timer_.Elapsed().InMilliseconds();
// Compute the delta between start and stop, in microseconds.
AddSample(static_cast<int>(sample));
timer_.Stop();
}
Logger::CallEventLogger(isolate(), name(), Logger::END, true);
@ -61,13 +64,13 @@ Counters::Counters(Isolate* isolate) {
HISTOGRAM_RANGE_LIST(HR)
#undef HR
#define HT(name, caption) \
name##_ = HistogramTimer(#caption, 0, 10000, 50, isolate);
#define HT(name, caption, max, res) \
name##_ = HistogramTimer(#caption, 0, max, HistogramTimer::res, 50, isolate);
HISTOGRAM_TIMER_LIST(HT)
#undef HT
#define AHT(name, caption) \
name##_ = AggregatableHistogramTimer(#caption, 0, 10000, 50, isolate);
name##_ = AggregatableHistogramTimer(#caption, 0, 10000000, 50, isolate);
AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT)
#undef AHT
@ -157,7 +160,7 @@ void Counters::ResetHistograms() {
HISTOGRAM_RANGE_LIST(HR)
#undef HR
#define HT(name, caption) name##_.Reset();
#define HT(name, caption, max, res) name##_.Reset();
HISTOGRAM_TIMER_LIST(HT)
#undef HT

View File

@ -224,13 +224,16 @@ class Histogram {
// A HistogramTimer allows distributions of results to be created.
class HistogramTimer : public Histogram {
public:
HistogramTimer() { }
HistogramTimer(const char* name,
int min,
int max,
int num_buckets,
Isolate* isolate)
: Histogram(name, min, max, num_buckets, isolate) {}
enum Resolution {
MILLISECOND,
MICROSECOND
};
HistogramTimer() {}
HistogramTimer(const char* name, int min, int max, Resolution resolution,
int num_buckets, Isolate* isolate)
: Histogram(name, min, max, num_buckets, isolate),
resolution_(resolution) {}
// Start the timer.
void Start();
@ -250,6 +253,7 @@ class HistogramTimer : public Histogram {
private:
base::ElapsedTimer timer_;
Resolution resolution_;
};
// Helper class for scoping a HistogramTimer.
@ -315,7 +319,7 @@ class AggregatableHistogramTimer : public Histogram {
// Start/stop the "outer" scope.
void Start() { time_ = base::TimeDelta(); }
void Stop() { AddSample(static_cast<int>(time_.InMilliseconds())); }
void Stop() { AddSample(static_cast<int>(time_.InMicroseconds())); }
// Add a time value ("inner" scope).
void Add(base::TimeDelta other) { time_ += other; }
@ -360,30 +364,33 @@ class AggregatedHistogramTimerScope {
HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \
HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, 101)
#define HISTOGRAM_TIMER_LIST(HT) \
/* Garbage collection timers. */ \
HT(gc_compactor, V8.GCCompactor) \
HT(gc_scavenger, V8.GCScavenger) \
HT(gc_context, V8.GCContext) /* GC context cleanup time */ \
HT(gc_idle_notification, V8.GCIdleNotification) \
HT(gc_incremental_marking, V8.GCIncrementalMarking) \
HT(gc_low_memory_notification, V8.GCLowMemoryNotification) \
/* Parsing timers. */ \
HT(parse, V8.Parse) \
HT(parse_lazy, V8.ParseLazy) \
HT(pre_parse, V8.PreParse) \
/* Compilation times. */ \
HT(compile, V8.Compile) \
HT(compile_eval, V8.CompileEval) \
/* Serialization as part of compilation (code caching) */ \
HT(compile_serialize, V8.CompileSerialize) \
HT(compile_deserialize, V8.CompileDeserialize) \
/* Total compilation time incl. caching/parsing */ \
HT(compile_script, V8.CompileScript)
#define HISTOGRAM_TIMER_LIST(HT) \
/* Garbage collection timers. */ \
HT(gc_compactor, V8.GCCompactor, 10000, MILLISECOND) \
HT(gc_scavenger, V8.GCScavenger, 10000, MILLISECOND) \
HT(gc_context, V8.GCContext, 10000, \
MILLISECOND) /* GC context cleanup time */ \
HT(gc_idle_notification, V8.GCIdleNotification, 10000, MILLISECOND) \
HT(gc_incremental_marking, V8.GCIncrementalMarking, 10000, MILLISECOND) \
HT(gc_low_memory_notification, V8.GCLowMemoryNotification, 10000, \
MILLISECOND) \
/* Parsing timers. */ \
HT(parse, V8.ParseMicroSeconds, 1000000, MICROSECOND) \
HT(parse_lazy, V8.ParseLazyMicroSeconds, 1000000, MICROSECOND) \
HT(pre_parse, V8.PreParseMicroSeconds, 1000000, MICROSECOND) \
/* Compilation times. */ \
HT(compile, V8.CompileMicroSeconds, 1000000, MICROSECOND) \
HT(compile_eval, V8.CompileEvalMicroSeconds, 1000000, MICROSECOND) \
/* Serialization as part of compilation (code caching) */ \
HT(compile_serialize, V8.CompileSerializeMicroSeconds, 100000, MICROSECOND) \
HT(compile_deserialize, V8.CompileDeserializeMicroSeconds, 1000000, \
MICROSECOND) \
/* Total compilation time incl. caching/parsing */ \
HT(compile_script, V8.CompileScriptMicroSeconds, 1000000, MICROSECOND)
#define AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) \
AHT(compile_lazy, V8.CompileLazy)
AHT(compile_lazy, V8.CompileLazyMicroSeconds)
#define HISTOGRAM_PERCENTAGE_LIST(HP) \
@ -631,7 +638,7 @@ class Counters {
HISTOGRAM_RANGE_LIST(HR)
#undef HR
#define HT(name, caption) \
#define HT(name, caption, max, res) \
HistogramTimer* name() { return &name##_; }
HISTOGRAM_TIMER_LIST(HT)
#undef HT
@ -688,7 +695,7 @@ class Counters {
#undef SC
enum Id {
#define RATE_ID(name, caption) k_##name,
#define RATE_ID(name, caption, max, res) k_##name,
HISTOGRAM_TIMER_LIST(RATE_ID)
#undef RATE_ID
#define AGGREGATABLE_ID(name, caption) k_##name,
@ -730,8 +737,7 @@ class Counters {
HISTOGRAM_RANGE_LIST(HR)
#undef HR
#define HT(name, caption) \
HistogramTimer name##_;
#define HT(name, caption, max, res) HistogramTimer name##_;
HISTOGRAM_TIMER_LIST(HT)
#undef HT

View File

@ -23649,7 +23649,7 @@ TEST(EventLogging) {
v8::Isolate* isolate = CcTest::isolate();
isolate->SetEventLogger(StoringEventLoggerCallback);
v8::internal::HistogramTimer histogramTimer(
"V8.Test", 0, 10000, 50,
"V8.Test", 0, 10000, v8::internal::HistogramTimer::MILLISECOND, 50,
reinterpret_cast<v8::internal::Isolate*>(isolate));
histogramTimer.Start();
CHECK_EQ("V8.Test", last_event_message);