| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 15 matching lines...) Expand all Loading... |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "counters.h" | 30 #include "counters.h" |
| 31 #include "platform.h" | 31 #include "platform.h" |
| 32 | 32 |
| 33 namespace v8 { namespace internal { | 33 namespace v8 { namespace internal { |
| 34 | 34 |
| 35 CounterLookupCallback StatsTable::lookup_function_ = NULL; | 35 CounterLookupCallback StatsTable::lookup_function_ = NULL; |
| 36 CreateHistogramCallback StatsTable::create_histogram_function_ = NULL; |
| 37 AddHistogramSampleCallback StatsTable::add_histogram_sample_function_ = NULL; |
| 36 | 38 |
| 37 // Start the timer. | 39 // Start the timer. |
| 38 void StatsCounterTimer::Start() { | 40 void StatsCounterTimer::Start() { |
| 39 if (!counter_.Enabled()) | 41 if (!counter_.Enabled()) |
| 40 return; | 42 return; |
| 41 stop_time_ = 0; | 43 stop_time_ = 0; |
| 42 start_time_ = OS::Ticks(); | 44 start_time_ = OS::Ticks(); |
| 43 } | 45 } |
| 44 | 46 |
| 45 // Stop the timer and record the results. | 47 // Stop the timer and record the results. |
| 46 void StatsCounterTimer::Stop() { | 48 void StatsCounterTimer::Stop() { |
| 47 if (!counter_.Enabled()) | 49 if (!counter_.Enabled()) |
| 48 return; | 50 return; |
| 49 stop_time_ = OS::Ticks(); | 51 stop_time_ = OS::Ticks(); |
| 50 | 52 |
| 51 // Compute the delta between start and stop, in milliseconds. | 53 // Compute the delta between start and stop, in milliseconds. |
| 52 int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000; | 54 int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000; |
| 53 counter_.Increment(milliseconds); | 55 counter_.Increment(milliseconds); |
| 54 } | 56 } |
| 55 | 57 |
| 58 // Start the timer. |
| 59 void HistogramTimer::Start() { |
| 60 if (GetHistogram() != NULL) { |
| 61 stop_time_ = 0; |
| 62 start_time_ = OS::Ticks(); |
| 63 } |
| 64 } |
| 65 |
| 66 // Stop the timer and record the results. |
| 67 void HistogramTimer::Stop() { |
| 68 if (histogram_ != NULL) { |
| 69 stop_time_ = OS::Ticks(); |
| 70 |
| 71 // Compute the delta between start and stop, in milliseconds. |
| 72 int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000; |
| 73 StatsTable::AddHistogramSample(histogram_, milliseconds); |
| 74 } |
| 75 } |
| 76 |
| 56 } } // namespace v8::internal | 77 } } // namespace v8::internal |
| OLD | NEW |