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

Side by Side Diff: runtime/vm/timeline.cc

Issue 1367973004: Make timeline use the same clock source as mojo's tracing infrastructure (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 | « runtime/vm/os_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <cstdlib> 5 #include <cstdlib>
6 6
7 #include "vm/atomic.h" 7 #include "vm/atomic.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/json_stream.h" 9 #include "vm/json_stream.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 thread_ = OSThread::kInvalidThreadId; 203 thread_ = OSThread::kInvalidThreadId;
204 isolate_ = NULL; 204 isolate_ = NULL;
205 category_ = ""; 205 category_ = "";
206 label_ = NULL; 206 label_ = NULL;
207 FreeArguments(); 207 FreeArguments();
208 } 208 }
209 209
210 210
211 void TimelineEvent::AsyncBegin(const char* label, int64_t async_id) { 211 void TimelineEvent::AsyncBegin(const char* label, int64_t async_id) {
212 Init(kAsyncBegin, label); 212 Init(kAsyncBegin, label);
213 timestamp0_ = OS::GetCurrentTimeMicros(); 213 timestamp0_ = OS::GetCurrentTraceMicros();
214 // Overload timestamp1_ with the async_id. 214 // Overload timestamp1_ with the async_id.
215 timestamp1_ = async_id; 215 timestamp1_ = async_id;
216 } 216 }
217 217
218 218
219 void TimelineEvent::AsyncInstant(const char* label, 219 void TimelineEvent::AsyncInstant(const char* label,
220 int64_t async_id) { 220 int64_t async_id) {
221 Init(kAsyncInstant, label); 221 Init(kAsyncInstant, label);
222 timestamp0_ = OS::GetCurrentTimeMicros(); 222 timestamp0_ = OS::GetCurrentTraceMicros();
223 // Overload timestamp1_ with the async_id. 223 // Overload timestamp1_ with the async_id.
224 timestamp1_ = async_id; 224 timestamp1_ = async_id;
225 } 225 }
226 226
227 227
228 void TimelineEvent::AsyncEnd(const char* label, 228 void TimelineEvent::AsyncEnd(const char* label,
229 int64_t async_id) { 229 int64_t async_id) {
230 Init(kAsyncEnd, label); 230 Init(kAsyncEnd, label);
231 timestamp0_ = OS::GetCurrentTimeMicros(); 231 timestamp0_ = OS::GetCurrentTraceMicros();
232 // Overload timestamp1_ with the async_id. 232 // Overload timestamp1_ with the async_id.
233 timestamp1_ = async_id; 233 timestamp1_ = async_id;
234 } 234 }
235 235
236 236
237 void TimelineEvent::DurationBegin(const char* label) { 237 void TimelineEvent::DurationBegin(const char* label) {
238 Init(kDuration, label); 238 Init(kDuration, label);
239 timestamp0_ = OS::GetCurrentTimeMicros(); 239 timestamp0_ = OS::GetCurrentTraceMicros();
240 } 240 }
241 241
242 242
243 void TimelineEvent::DurationEnd() { 243 void TimelineEvent::DurationEnd() {
244 timestamp1_ = OS::GetCurrentTimeMicros(); 244 timestamp1_ = OS::GetCurrentTraceMicros();
245 } 245 }
246 246
247 247
248 void TimelineEvent::Instant(const char* label) { 248 void TimelineEvent::Instant(const char* label) {
249 Init(kInstant, label); 249 Init(kInstant, label);
250 timestamp0_ = OS::GetCurrentTimeMicros(); 250 timestamp0_ = OS::GetCurrentTraceMicros();
251 } 251 }
252 252
253 253
254 void TimelineEvent::Duration(const char* label, 254 void TimelineEvent::Duration(const char* label,
255 int64_t start_micros, 255 int64_t start_micros,
256 int64_t end_micros) { 256 int64_t end_micros) {
257 Init(kDuration, label); 257 Init(kDuration, label);
258 timestamp0_ = start_micros; 258 timestamp0_ = start_micros;
259 timestamp1_ = end_micros; 259 timestamp1_ = end_micros;
260 } 260 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 348
349 349
350 void TimelineEvent::PrintJSON(JSONStream* stream) const { 350 void TimelineEvent::PrintJSON(JSONStream* stream) const {
351 JSONObject obj(stream); 351 JSONObject obj(stream);
352 int64_t pid = OS::ProcessId(); 352 int64_t pid = OS::ProcessId();
353 int64_t tid = OSThread::ThreadIdToIntPtr(thread_); 353 int64_t tid = OSThread::ThreadIdToIntPtr(thread_);
354 obj.AddProperty("name", label_); 354 obj.AddProperty("name", label_);
355 obj.AddProperty("cat", category_); 355 obj.AddProperty("cat", category_);
356 obj.AddProperty64("tid", tid); 356 obj.AddProperty64("tid", tid);
357 obj.AddProperty64("pid", pid); 357 obj.AddProperty64("pid", pid);
358 obj.AddPropertyTimeMillis("ts", TimeOrigin()); 358 obj.AddPropertyTimeMicros("ts", TimeOrigin());
359 359
360 switch (event_type()) { 360 switch (event_type()) {
361 case kDuration: { 361 case kDuration: {
362 obj.AddProperty("ph", "X"); 362 obj.AddProperty("ph", "X");
363 obj.AddPropertyTimeMillis("dur", TimeDuration()); 363 obj.AddPropertyTimeMicros("dur", TimeDuration());
364 } 364 }
365 break; 365 break;
366 case kInstant: { 366 case kInstant: {
367 obj.AddProperty("ph", "i"); 367 obj.AddProperty("ph", "i");
368 obj.AddProperty("s", "p"); 368 obj.AddProperty("s", "p");
369 } 369 }
370 break; 370 break;
371 case kAsyncBegin: { 371 case kAsyncBegin: {
372 obj.AddProperty("ph", "b"); 372 obj.AddProperty("ph", "b");
373 obj.AddPropertyF("id", "%" Px64 "", AsyncId()); 373 obj.AddPropertyF("id", "%" Px64 "", AsyncId());
(...skipping 28 matching lines...) Expand all
402 402
403 403
404 int64_t TimelineEvent::AsyncId() const { 404 int64_t TimelineEvent::AsyncId() const {
405 return timestamp1_; 405 return timestamp1_;
406 } 406 }
407 407
408 408
409 int64_t TimelineEvent::TimeDuration() const { 409 int64_t TimelineEvent::TimeDuration() const {
410 if (timestamp1_ == 0) { 410 if (timestamp1_ == 0) {
411 // This duration is still open, use current time as end. 411 // This duration is still open, use current time as end.
412 return OS::GetCurrentTimeMicros() - timestamp0_; 412 return OS::GetCurrentTraceMicros() - timestamp0_;
413 } 413 }
414 return timestamp1_ - timestamp0_; 414 return timestamp1_ - timestamp0_;
415 } 415 }
416 416
417 417
418 TimelineStream::TimelineStream() 418 TimelineStream::TimelineStream()
419 : name_(NULL), 419 : name_(NULL),
420 enabled_(false), 420 enabled_(false),
421 globally_enabled_(NULL) { 421 globally_enabled_(NULL) {
422 } 422 }
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 994
995 995
996 TimelineEventBlock* TimelineEventBlockIterator::Next() { 996 TimelineEventBlock* TimelineEventBlockIterator::Next() {
997 ASSERT(current_ != NULL); 997 ASSERT(current_ != NULL);
998 TimelineEventBlock* r = current_; 998 TimelineEventBlock* r = current_;
999 current_ = current_->next(); 999 current_ = current_->next();
1000 return r; 1000 return r;
1001 } 1001 }
1002 1002
1003 } // namespace dart 1003 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/os_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698