OLD | NEW |
1 // Copyright 2007-2008 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 void StatsCounterTimer::Stop() { | 57 void StatsCounterTimer::Stop() { |
58 if (!counter_.Enabled()) | 58 if (!counter_.Enabled()) |
59 return; | 59 return; |
60 stop_time_ = OS::Ticks(); | 60 stop_time_ = OS::Ticks(); |
61 | 61 |
62 // Compute the delta between start and stop, in milliseconds. | 62 // Compute the delta between start and stop, in milliseconds. |
63 int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000; | 63 int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000; |
64 counter_.Increment(milliseconds); | 64 counter_.Increment(milliseconds); |
65 } | 65 } |
66 | 66 |
| 67 void Histogram::AddSample(int sample) { |
| 68 if (Enabled()) { |
| 69 Isolate::Current()->stats_table()->AddHistogramSample(histogram_, sample); |
| 70 } |
| 71 } |
| 72 |
| 73 void* Histogram::CreateHistogram() const { |
| 74 return Isolate::Current()->stats_table()-> |
| 75 CreateHistogram(name_, min_, max_, num_buckets_); |
| 76 } |
| 77 |
67 // Start the timer. | 78 // Start the timer. |
68 void HistogramTimer::Start() { | 79 void HistogramTimer::Start() { |
69 if (GetHistogram() != NULL) { | 80 if (histogram_.Enabled()) { |
70 stop_time_ = 0; | 81 stop_time_ = 0; |
71 start_time_ = OS::Ticks(); | 82 start_time_ = OS::Ticks(); |
72 } | 83 } |
73 } | 84 } |
74 | 85 |
75 // Stop the timer and record the results. | 86 // Stop the timer and record the results. |
76 void HistogramTimer::Stop() { | 87 void HistogramTimer::Stop() { |
77 if (histogram_ != NULL) { | 88 if (histogram_.Enabled()) { |
78 stop_time_ = OS::Ticks(); | 89 stop_time_ = OS::Ticks(); |
79 | 90 |
80 // Compute the delta between start and stop, in milliseconds. | 91 // Compute the delta between start and stop, in milliseconds. |
81 int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000; | 92 int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000; |
82 Isolate::Current()->stats_table()-> | 93 histogram_.AddSample(milliseconds); |
83 AddHistogramSample(histogram_, milliseconds); | |
84 } | 94 } |
85 } | 95 } |
86 | 96 |
87 | |
88 void* HistogramTimer::CreateHistogram() const { | |
89 return Isolate::Current()->stats_table()-> | |
90 CreateHistogram(name_, 0, 10000, 50); | |
91 } | |
92 | |
93 } } // namespace v8::internal | 97 } } // namespace v8::internal |
OLD | NEW |