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

Side by Side Diff: src/counters.cc

Issue 2418303002: Use TracedValue in runtime statistics. (Closed)
Patch Set: Created 4 years, 2 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/tracing/trace-event.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/counters.h" 5 #include "src/counters.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 8
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 uint64_t total_call_count = 0; 269 uint64_t total_call_count = 0;
270 base::TimeDelta total_time; 270 base::TimeDelta total_time;
271 std::vector<Entry> entries; 271 std::vector<Entry> entries;
272 }; 272 };
273 273
274 void RuntimeCallCounter::Reset() { 274 void RuntimeCallCounter::Reset() {
275 count = 0; 275 count = 0;
276 time = base::TimeDelta(); 276 time = base::TimeDelta();
277 } 277 }
278 278
279 void RuntimeCallCounter::Dump(std::stringstream& out) {
280 out << "\"" << name << "\":[" << count << "," << time.InMicroseconds()
281 << "],";
282 }
283
284 // static 279 // static
285 void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer, 280 void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer,
286 CounterId counter_id) { 281 CounterId counter_id) {
287 RuntimeCallCounter* counter = &(stats->*counter_id); 282 RuntimeCallCounter* counter = &(stats->*counter_id);
288 timer->Start(counter, stats->current_timer_); 283 timer->Start(counter, stats->current_timer_);
289 stats->current_timer_ = timer; 284 stats->current_timer_ = timer;
290 } 285 }
291 286
292 // static 287 // static
293 void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) { 288 void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 FOR_EACH_API_COUNTER(RESET_COUNTER) 352 FOR_EACH_API_COUNTER(RESET_COUNTER)
358 #undef RESET_COUNTER 353 #undef RESET_COUNTER
359 354
360 #define RESET_COUNTER(name) this->Handler_##name.Reset(); 355 #define RESET_COUNTER(name) this->Handler_##name.Reset();
361 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER) 356 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER)
362 #undef RESET_COUNTER 357 #undef RESET_COUNTER
363 358
364 in_use_ = true; 359 in_use_ = true;
365 } 360 }
366 361
367 std::string RuntimeCallStats::Dump() { 362 void RuntimeCallStats::Dump(v8::tracing::TracedValue* value) {
368 buffer_.str(std::string()); 363 #define DUMP(counter) \
369 buffer_.clear(); 364 if (counter.count > 0) { \
370 buffer_ << "{"; 365 value->BeginArray(counter.name); \
366 value->AppendLongInteger(counter.count); \
367 value->AppendLongInteger(counter.time.InMicroseconds()); \
368 value->EndArray(); \
369 }
Camillo Bruni 2016/10/18 07:52:24 Please leave the separate function in place as the
lpy 2016/10/18 19:43:44 Done.
370
371 #define DUMP_COUNTER(name) \ 371 #define DUMP_COUNTER(name) \
372 if (this->name.count > 0) this->name.Dump(buffer_); 372 if (this->name.count > 0) DUMP(this->name)
373 FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER) 373 FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER)
374 #undef DUMP_COUNTER 374 #undef DUMP_COUNTER
375 375
376 #define DUMP_COUNTER(name, nargs, result_size) \ 376 #define DUMP_COUNTER(name, nargs, result_size) \
377 if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(buffer_); 377 if (this->Runtime_##name.count > 0) DUMP(this->Runtime_##name);
378 FOR_EACH_INTRINSIC(DUMP_COUNTER) 378 FOR_EACH_INTRINSIC(DUMP_COUNTER)
379 #undef DUMP_COUNTER 379 #undef DUMP_COUNTER
380 380
381 #define DUMP_COUNTER(name) \ 381 #define DUMP_COUNTER(name) \
382 if (this->Builtin_##name.count > 0) this->Builtin_##name.Dump(buffer_); 382 if (this->Builtin_##name.count > 0) DUMP(this->Builtin_##name);
383 BUILTIN_LIST_C(DUMP_COUNTER) 383 BUILTIN_LIST_C(DUMP_COUNTER)
384 #undef DUMP_COUNTER 384 #undef DUMP_COUNTER
385 385
386 #define DUMP_COUNTER(name) \ 386 #define DUMP_COUNTER(name) \
387 if (this->API_##name.count > 0) this->API_##name.Dump(buffer_); 387 if (this->API_##name.count > 0) DUMP(this->API_##name);
388 FOR_EACH_API_COUNTER(DUMP_COUNTER) 388 FOR_EACH_API_COUNTER(DUMP_COUNTER)
389 #undef DUMP_COUNTER 389 #undef DUMP_COUNTER
390 390
391 #define DUMP_COUNTER(name) \ 391 #define DUMP_COUNTER(name) \
392 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(buffer_); 392 if (this->Handler_##name.count > 0) DUMP(this->Handler_##name);
393 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) 393 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER)
394 #undef DUMP_COUNTER 394 #undef DUMP_COUNTER
395 buffer_ << "\"END\":[]}"; 395
396 in_use_ = false; 396 in_use_ = false;
397 return buffer_.str(); 397
398 #undef DUMP
398 } 399 }
399 400
400 } // namespace internal 401 } // namespace internal
401 } // namespace v8 402 } // namespace v8
OLDNEW
« no previous file with comments | « src/counters.h ('k') | src/tracing/trace-event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698