| OLD | NEW |
| 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 <cstring> | 5 #include <cstring> |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 | 8 |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 OS::Sleep(1); | 315 OS::Sleep(1); |
| 316 | 316 |
| 317 // Add events to each block for thread 2. | 317 // Add events to each block for thread 2. |
| 318 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "A"); | 318 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "A"); |
| 319 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "B"); | 319 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "B"); |
| 320 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "C"); | 320 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "C"); |
| 321 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "D"); | 321 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "D"); |
| 322 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "E"); | 322 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "E"); |
| 323 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "F"); | 323 TimelineTestHelper::FakeThreadEvent(block_2_0, 2, "F"); |
| 324 | 324 |
| 325 Thread* thread = Thread::Current(); | |
| 326 Zone* zone = thread->zone(); | 325 Zone* zone = thread->zone(); |
| 327 Isolate* isolate = thread->isolate(); | 326 Isolate* isolate = thread->isolate(); |
| 328 | 327 |
| 329 // Discover threads in recorder. | 328 // Discover threads in recorder. |
| 330 TimelineAnalysis ta(zone, isolate, recorder); | 329 TimelineAnalysis ta(zone, isolate, recorder); |
| 331 ta.BuildThreads(); | 330 ta.BuildThreads(); |
| 332 // block_3_0 is never used by a thread, so we only have two threads. | 331 // block_3_0 is never used by a thread, so we only have two threads. |
| 333 EXPECT_EQ(2, ta.NumThreads()); | 332 EXPECT_EQ(2, ta.NumThreads()); |
| 334 | 333 |
| 335 // Extract both threads. | 334 // Extract both threads. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 // block. | 432 // block. |
| 434 const char* alpha = strstr(js.ToCString(), "Alpha"); | 433 const char* alpha = strstr(js.ToCString(), "Alpha"); |
| 435 const char* beta = strstr(js.ToCString(), "Beta"); | 434 const char* beta = strstr(js.ToCString(), "Beta"); |
| 436 EXPECT(alpha < beta); | 435 EXPECT(alpha < beta); |
| 437 } | 436 } |
| 438 | 437 |
| 439 | 438 |
| 440 TEST_CASE(TimelinePauses_Basic) { | 439 TEST_CASE(TimelinePauses_Basic) { |
| 441 TimelineEventEndlessRecorder* recorder = new TimelineEventEndlessRecorder(); | 440 TimelineEventEndlessRecorder* recorder = new TimelineEventEndlessRecorder(); |
| 442 ASSERT(recorder != NULL); | 441 ASSERT(recorder != NULL); |
| 443 Thread* thread = Thread::Current(); | |
| 444 Zone* zone = thread->zone(); | 442 Zone* zone = thread->zone(); |
| 445 Isolate* isolate = thread->isolate(); | 443 Isolate* isolate = thread->isolate(); |
| 446 ThreadId tid = OSThread::GetCurrentThreadId(); | 444 ThreadId tid = OSThread::GetCurrentThreadId(); |
| 447 | 445 |
| 448 // Test case. | 446 // Test case. |
| 449 TimelineTestHelper::FakeDuration(recorder, "a", 0, 10); | 447 TimelineTestHelper::FakeDuration(recorder, "a", 0, 10); |
| 450 { | 448 { |
| 451 TimelinePauses pauses(zone, isolate, recorder); | 449 TimelinePauses pauses(zone, isolate, recorder); |
| 452 pauses.Setup(); | 450 pauses.Setup(); |
| 453 pauses.CalculatePauseTimesForThread(tid); | 451 pauses.CalculatePauseTimesForThread(tid); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 EXPECT(!pauses.has_error()); | 599 EXPECT(!pauses.has_error()); |
| 602 EXPECT_EQ(10, pauses.InclusiveTime("a")); | 600 EXPECT_EQ(10, pauses.InclusiveTime("a")); |
| 603 EXPECT_EQ(10, pauses.ExclusiveTime("a")); | 601 EXPECT_EQ(10, pauses.ExclusiveTime("a")); |
| 604 EXPECT_EQ(10, pauses.MaxInclusiveTime("a")); | 602 EXPECT_EQ(10, pauses.MaxInclusiveTime("a")); |
| 605 EXPECT_EQ(8, pauses.MaxExclusiveTime("a")); | 603 EXPECT_EQ(8, pauses.MaxExclusiveTime("a")); |
| 606 } | 604 } |
| 607 TimelineTestHelper::Clear(recorder); | 605 TimelineTestHelper::Clear(recorder); |
| 608 } | 606 } |
| 609 | 607 |
| 610 } // namespace dart | 608 } // namespace dart |
| OLD | NEW |