OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 27 matching lines...) Expand all Loading... |
38 : lookup_function_(NULL), | 38 : lookup_function_(NULL), |
39 create_histogram_function_(NULL), | 39 create_histogram_function_(NULL), |
40 add_histogram_sample_function_(NULL) {} | 40 add_histogram_sample_function_(NULL) {} |
41 | 41 |
42 | 42 |
43 int* StatsCounter::FindLocationInStatsTable() const { | 43 int* StatsCounter::FindLocationInStatsTable() const { |
44 return Isolate::Current()->stats_table()->FindLocation(name_); | 44 return Isolate::Current()->stats_table()->FindLocation(name_); |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 // Start the timer. | |
49 void StatsCounterTimer::Start() { | |
50 if (!counter_.Enabled()) | |
51 return; | |
52 stop_time_ = 0; | |
53 start_time_ = OS::Ticks(); | |
54 } | |
55 | |
56 // Stop the timer and record the results. | |
57 void StatsCounterTimer::Stop() { | |
58 if (!counter_.Enabled()) | |
59 return; | |
60 stop_time_ = OS::Ticks(); | |
61 | |
62 // Compute the delta between start and stop, in milliseconds. | |
63 int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000; | |
64 counter_.Increment(milliseconds); | |
65 } | |
66 | |
67 void Histogram::AddSample(int sample) { | 48 void Histogram::AddSample(int sample) { |
68 if (Enabled()) { | 49 if (Enabled()) { |
69 Isolate::Current()->stats_table()->AddHistogramSample(histogram_, sample); | 50 isolate()->stats_table()->AddHistogramSample(histogram_, sample); |
70 } | 51 } |
71 } | 52 } |
72 | 53 |
73 void* Histogram::CreateHistogram() const { | 54 void* Histogram::CreateHistogram() const { |
74 return Isolate::Current()->stats_table()-> | 55 return isolate()->stats_table()-> |
75 CreateHistogram(name_, min_, max_, num_buckets_); | 56 CreateHistogram(name_, min_, max_, num_buckets_); |
76 } | 57 } |
77 | 58 |
78 // Start the timer. | 59 // Start the timer. |
79 void HistogramTimer::Start() { | 60 void HistogramTimer::Start() { |
80 if (histogram_.Enabled()) { | 61 if (Enabled()) { |
81 stop_time_ = 0; | 62 stop_time_ = 0; |
82 start_time_ = OS::Ticks(); | 63 start_time_ = OS::Ticks(); |
83 } | 64 } |
84 if (FLAG_log_internal_timer_events) { | 65 if (FLAG_log_internal_timer_events) { |
85 LOG(Isolate::Current(), TimerEvent(Logger::START, histogram_.name_)); | 66 LOG(isolate(), TimerEvent(Logger::START, name())); |
86 } | 67 } |
87 } | 68 } |
88 | 69 |
89 // Stop the timer and record the results. | 70 // Stop the timer and record the results. |
90 void HistogramTimer::Stop() { | 71 void HistogramTimer::Stop() { |
91 if (histogram_.Enabled()) { | 72 if (Enabled()) { |
92 stop_time_ = OS::Ticks(); | 73 stop_time_ = OS::Ticks(); |
93 // Compute the delta between start and stop, in milliseconds. | 74 // Compute the delta between start and stop, in milliseconds. |
94 int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000; | 75 int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000; |
95 histogram_.AddSample(milliseconds); | 76 AddSample(milliseconds); |
96 } | 77 } |
97 if (FLAG_log_internal_timer_events) { | 78 if (FLAG_log_internal_timer_events) { |
98 LOG(Isolate::Current(), TimerEvent(Logger::END, histogram_.name_)); | 79 LOG(isolate(), TimerEvent(Logger::END, name())); |
99 } | 80 } |
100 } | 81 } |
101 | 82 |
102 } } // namespace v8::internal | 83 } } // namespace v8::internal |
OLD | NEW |