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

Side by Side Diff: src/profile-generator.cc

Issue 23295034: Add Chromium-style TimeDelta, Time and TimeTicks classes, and a new ElapsedTimer class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 7 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 | Annotate | Revision Log
OLDNEW
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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 OS::Print("root: %u %u %.2fms %.2fms\n", 369 OS::Print("root: %u %u %.2fms %.2fms\n",
370 root_->total_ticks(), root_->self_ticks(), 370 root_->total_ticks(), root_->self_ticks(),
371 root_->GetTotalMillis(), root_->GetSelfMillis()); 371 root_->GetTotalMillis(), root_->GetSelfMillis());
372 } 372 }
373 373
374 374
375 CpuProfile::CpuProfile(const char* title, unsigned uid, bool record_samples) 375 CpuProfile::CpuProfile(const char* title, unsigned uid, bool record_samples)
376 : title_(title), 376 : title_(title),
377 uid_(uid), 377 uid_(uid),
378 record_samples_(record_samples), 378 record_samples_(record_samples),
379 start_time_us_(OS::Ticks()), 379 start_time_(Time::NowFromSystemTime()) {
380 end_time_us_(0) { 380 timer_.Start();
381 } 381 }
382 382
383 383
384 void CpuProfile::AddPath(const Vector<CodeEntry*>& path) { 384 void CpuProfile::AddPath(const Vector<CodeEntry*>& path) {
385 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path); 385 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path);
386 if (record_samples_) samples_.Add(top_frame_node); 386 if (record_samples_) samples_.Add(top_frame_node);
387 } 387 }
388 388
389 389
390 void CpuProfile::CalculateTotalTicksAndSamplingRate() { 390 void CpuProfile::CalculateTotalTicksAndSamplingRate() {
391 end_time_us_ = OS::Ticks(); 391 TimeDelta duration = timer_.Elapsed();
392 end_time_ = start_time_ + duration;
392 top_down_.CalculateTotalTicks(); 393 top_down_.CalculateTotalTicks();
393 394
394 double duration_ms = (end_time_us_ - start_time_us_) / 1000.; 395 double duration_ms = duration.InMillisecondsF();
395 if (duration_ms < 1) duration_ms = 1; 396 if (duration_ms < 1) duration_ms = 1;
396 unsigned ticks = top_down_.root()->total_ticks(); 397 unsigned ticks = top_down_.root()->total_ticks();
397 double rate = ticks / duration_ms; 398 double rate = ticks / duration_ms;
398 top_down_.SetTickRatePerMs(rate); 399 top_down_.SetTickRatePerMs(rate);
399 } 400 }
400 401
401 402
402 void CpuProfile::ShortPrint() { 403 void CpuProfile::ShortPrint() {
403 OS::Print("top down "); 404 OS::Print("top down ");
404 top_down_.ShortPrint(); 405 top_down_.ShortPrint();
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 if (no_symbolized_entries) { 708 if (no_symbolized_entries) {
708 *entry++ = EntryForVMState(sample.state); 709 *entry++ = EntryForVMState(sample.state);
709 } 710 }
710 } 711 }
711 712
712 profiles_->AddPathToCurrentProfiles(entries); 713 profiles_->AddPathToCurrentProfiles(entries);
713 } 714 }
714 715
715 716
716 } } // namespace v8::internal 717 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | src/time/elapsed-timer.h » ('j') | src/time/time.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698