2012-07-13 12:12:09 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#include "v8.h"
|
|
|
|
|
|
|
|
#include "counters.h"
|
2011-03-18 20:35:07 +00:00
|
|
|
#include "isolate.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
#include "platform.h"
|
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
StatsTable::StatsTable()
|
|
|
|
: lookup_function_(NULL),
|
|
|
|
create_histogram_function_(NULL),
|
|
|
|
add_histogram_sample_function_(NULL) {}
|
|
|
|
|
|
|
|
|
|
|
|
int* StatsCounter::FindLocationInStatsTable() const {
|
2013-09-03 06:57:16 +00:00
|
|
|
return isolate_->stats_table()->FindLocation(name_);
|
2011-03-18 20:35:07 +00:00
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2012-07-13 12:12:09 +00:00
|
|
|
void Histogram::AddSample(int sample) {
|
|
|
|
if (Enabled()) {
|
2013-04-24 13:52:26 +00:00
|
|
|
isolate()->stats_table()->AddHistogramSample(histogram_, sample);
|
2012-07-13 12:12:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void* Histogram::CreateHistogram() const {
|
2013-04-24 13:52:26 +00:00
|
|
|
return isolate()->stats_table()->
|
2012-07-13 12:12:09 +00:00
|
|
|
CreateHistogram(name_, min_, max_, num_buckets_);
|
|
|
|
}
|
|
|
|
|
2013-07-05 09:52:11 +00:00
|
|
|
|
2009-03-13 16:06:31 +00:00
|
|
|
// Start the timer.
|
|
|
|
void HistogramTimer::Start() {
|
2013-04-24 13:52:26 +00:00
|
|
|
if (Enabled()) {
|
2013-08-29 09:15:13 +00:00
|
|
|
timer_.Start();
|
2009-03-13 16:06:31 +00:00
|
|
|
}
|
2014-03-10 08:56:48 +00:00
|
|
|
isolate()->event_logger()(name(), Logger::START);
|
2009-03-13 16:06:31 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 09:52:11 +00:00
|
|
|
|
2009-03-13 16:06:31 +00:00
|
|
|
// Stop the timer and record the results.
|
|
|
|
void HistogramTimer::Stop() {
|
2013-04-24 13:52:26 +00:00
|
|
|
if (Enabled()) {
|
2009-03-13 16:06:31 +00:00
|
|
|
// Compute the delta between start and stop, in milliseconds.
|
2013-08-29 09:15:13 +00:00
|
|
|
AddSample(static_cast<int>(timer_.Elapsed().InMilliseconds()));
|
|
|
|
timer_.Stop();
|
2009-03-13 16:06:31 +00:00
|
|
|
}
|
2014-03-10 08:56:48 +00:00
|
|
|
isolate()->event_logger()(name(), Logger::END);
|
2009-03-13 16:06:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-07 07:15:24 +00:00
|
|
|
|
|
|
|
Counters::Counters(Isolate* isolate) {
|
|
|
|
#define HT(name, caption) \
|
|
|
|
name##_ = HistogramTimer(#caption, 0, 10000, 50, isolate);
|
|
|
|
HISTOGRAM_TIMER_LIST(HT)
|
|
|
|
#undef HT
|
|
|
|
|
|
|
|
#define HP(name, caption) \
|
|
|
|
name##_ = Histogram(#caption, 0, 101, 100, isolate);
|
|
|
|
HISTOGRAM_PERCENTAGE_LIST(HP)
|
|
|
|
#undef HP
|
|
|
|
|
|
|
|
#define HM(name, caption) \
|
|
|
|
name##_ = Histogram(#caption, 1000, 500000, 50, isolate);
|
|
|
|
HISTOGRAM_MEMORY_LIST(HM)
|
|
|
|
#undef HM
|
|
|
|
|
|
|
|
#define SC(name, caption) \
|
|
|
|
name##_ = StatsCounter(isolate, "c:" #caption);
|
|
|
|
|
|
|
|
STATS_COUNTER_LIST_1(SC)
|
|
|
|
STATS_COUNTER_LIST_2(SC)
|
|
|
|
#undef SC
|
|
|
|
|
|
|
|
#define SC(name) \
|
|
|
|
count_of_##name##_ = StatsCounter(isolate, "c:" "V8.CountOf_" #name); \
|
|
|
|
size_of_##name##_ = StatsCounter(isolate, "c:" "V8.SizeOf_" #name);
|
|
|
|
INSTANCE_TYPE_LIST(SC)
|
|
|
|
#undef SC
|
|
|
|
|
|
|
|
#define SC(name) \
|
|
|
|
count_of_CODE_TYPE_##name##_ = \
|
|
|
|
StatsCounter(isolate, "c:" "V8.CountOf_CODE_TYPE-" #name); \
|
|
|
|
size_of_CODE_TYPE_##name##_ = \
|
|
|
|
StatsCounter(isolate, "c:" "V8.SizeOf_CODE_TYPE-" #name);
|
|
|
|
CODE_KIND_LIST(SC)
|
|
|
|
#undef SC
|
|
|
|
|
|
|
|
#define SC(name) \
|
|
|
|
count_of_FIXED_ARRAY_##name##_ = \
|
|
|
|
StatsCounter(isolate, "c:" "V8.CountOf_FIXED_ARRAY-" #name); \
|
|
|
|
size_of_FIXED_ARRAY_##name##_ = \
|
|
|
|
StatsCounter(isolate, "c:" "V8.SizeOf_FIXED_ARRAY-" #name);
|
|
|
|
FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(SC)
|
|
|
|
#undef SC
|
|
|
|
|
|
|
|
#define SC(name) \
|
|
|
|
count_of_CODE_AGE_##name##_ = \
|
|
|
|
StatsCounter(isolate, "c:" "V8.CountOf_CODE_AGE-" #name); \
|
|
|
|
size_of_CODE_AGE_##name##_ = \
|
|
|
|
StatsCounter(isolate, "c:" "V8.SizeOf_CODE_AGE-" #name);
|
|
|
|
CODE_AGE_LIST_COMPLETE(SC)
|
|
|
|
#undef SC
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Counters::ResetHistograms() {
|
|
|
|
#define HT(name, caption) name##_.Reset();
|
|
|
|
HISTOGRAM_TIMER_LIST(HT)
|
|
|
|
#undef HT
|
|
|
|
|
|
|
|
#define HP(name, caption) name##_.Reset();
|
|
|
|
HISTOGRAM_PERCENTAGE_LIST(HP)
|
|
|
|
#undef HP
|
|
|
|
|
|
|
|
#define HM(name, caption) name##_.Reset();
|
|
|
|
HISTOGRAM_MEMORY_LIST(HM)
|
|
|
|
#undef HM
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
} } // namespace v8::internal
|