Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: src/counters.cc

Issue 2423: POD initialize StatsCounters (Closed)
Patch Set: Merge to HEAD Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/counters.h ('k') | src/v8-counters.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
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 36
37 StatsCounterTimer::StatsCounterTimer(const wchar_t* name)
38 : start_time_(0), // initialize to avoid compiler complaints
39 stop_time_(0) { // initialize to avoid compiler complaints
40 int len = wcslen(name);
41 // we prepend the name with 'c.' to indicate that it is a counter.
42 name_ = Vector<wchar_t>::New(len+3);
43 OS::WcsCpy(name_, L"t:");
44 OS::WcsCpy(name_ + 2, name);
45 }
46
47 // Start the timer. 37 // Start the timer.
48 void StatsCounterTimer::Start() { 38 void StatsCounterTimer::Start() {
49 if (!Enabled()) 39 if (!counter_.Enabled())
50 return; 40 return;
51 stop_time_ = 0; 41 stop_time_ = 0;
52 start_time_ = OS::Ticks(); 42 start_time_ = OS::Ticks();
53 } 43 }
54 44
55 // Stop the timer and record the results. 45 // Stop the timer and record the results.
56 void StatsCounterTimer::Stop() { 46 void StatsCounterTimer::Stop() {
57 if (!Enabled()) 47 if (!counter_.Enabled())
58 return; 48 return;
59 stop_time_ = OS::Ticks(); 49 stop_time_ = OS::Ticks();
60 Record(); 50
51 // Compute the delta between start and stop, in milliseconds.
52 int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000;
53 counter_.Increment(milliseconds);
61 } 54 }
62 55
63 } } // namespace v8::internal 56 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/counters.h ('k') | src/v8-counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698