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

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

Issue 1286093005: Fix MacOS build (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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_thread_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 "platform/assert.h" 5 #include "platform/assert.h"
6 6
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/timeline.h" 10 #include "vm/timeline.h"
11 #include "vm/timeline_analysis.h" 11 #include "vm/timeline_analysis.h"
12 #include "vm/unit_test.h" 12 #include "vm/unit_test.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 class TimelineTestHelper : public AllStatic { 16 class TimelineTestHelper : public AllStatic {
17 public: 17 public:
18 static void SetStream(TimelineEvent* event, TimelineStream* stream) { 18 static void SetStream(TimelineEvent* event, TimelineStream* stream) {
19 event->StreamInit(stream); 19 event->StreamInit(stream);
20 } 20 }
21 21
22 static TimelineEvent* FakeThreadEvent( 22 static TimelineEvent* FakeThreadEvent(
23 TimelineEventBlock* block, intptr_t ftid) { 23 TimelineEventBlock* block, intptr_t ftid) {
24 TimelineEvent* event = block->StartEvent(); 24 TimelineEvent* event = block->StartEvent();
25 ASSERT(event != NULL); 25 ASSERT(event != NULL);
26 event->DurationBegin("fake"); 26 event->DurationBegin("fake");
27 event->thread_ = static_cast<ThreadId>(ftid); 27 event->thread_ = OSThread::ThreadIdFromIntPtr(ftid);
28 return event; 28 return event;
29 } 29 }
30 }; 30 };
31 31
32 32
33 TEST_CASE(TimelineEventIsValid) { 33 TEST_CASE(TimelineEventIsValid) {
34 // Create a test stream. 34 // Create a test stream.
35 TimelineStream stream; 35 TimelineStream stream;
36 stream.Init("testStream", true); 36 stream.Init("testStream", true);
37 37
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 Zone* zone = thread->zone(); 273 Zone* zone = thread->zone();
274 Isolate* isolate = thread->isolate(); 274 Isolate* isolate = thread->isolate();
275 275
276 // Discover threads in recorder. 276 // Discover threads in recorder.
277 TimelineAnalysis ta(zone, isolate, recorder); 277 TimelineAnalysis ta(zone, isolate, recorder);
278 ta.BuildThreads(); 278 ta.BuildThreads();
279 // block_3_0 is never used by a thread, so we only have two threads. 279 // block_3_0 is never used by a thread, so we only have two threads.
280 EXPECT_EQ(2, ta.NumThreads()); 280 EXPECT_EQ(2, ta.NumThreads());
281 281
282 // Extract both threads. 282 // Extract both threads.
283 TimelineAnalysisThread* thread_1 = ta.GetThread(static_cast<ThreadId>(1)); 283 TimelineAnalysisThread* thread_1 =
284 TimelineAnalysisThread* thread_2 = ta.GetThread(static_cast<ThreadId>(2)); 284 ta.GetThread(OSThread::ThreadIdFromIntPtr(1));
285 EXPECT_EQ(static_cast<ThreadId>(1), thread_1->id()); 285 TimelineAnalysisThread* thread_2 =
286 EXPECT_EQ(static_cast<ThreadId>(2), thread_2->id()); 286 ta.GetThread(OSThread::ThreadIdFromIntPtr(2));
287 EXPECT_EQ(OSThread::ThreadIdFromIntPtr(1), thread_1->id());
288 EXPECT_EQ(OSThread::ThreadIdFromIntPtr(2), thread_2->id());
287 289
288 // Thread "1" should have three blocks. 290 // Thread "1" should have three blocks.
289 EXPECT_EQ(3, thread_1->NumBlocks()); 291 EXPECT_EQ(3, thread_1->NumBlocks());
290 292
291 // Verify that blocks for thread "1" are sorted based on start time. 293 // Verify that blocks for thread "1" are sorted based on start time.
292 EXPECT_EQ(thread_1->At(0), block_1_2); 294 EXPECT_EQ(thread_1->At(0), block_1_2);
293 EXPECT_EQ(thread_1->At(1), block_1_0); 295 EXPECT_EQ(thread_1->At(1), block_1_0);
294 EXPECT_EQ(thread_1->At(2), block_1_1); 296 EXPECT_EQ(thread_1->At(2), block_1_1);
295 297
296 // Verify that block_1_2 has three events. 298 // Verify that block_1_2 has three events.
297 EXPECT_EQ(3, block_1_2->length()); 299 EXPECT_EQ(3, block_1_2->length());
298 300
299 // Verify that block_1_0 has one events. 301 // Verify that block_1_0 has one events.
300 EXPECT_EQ(1, block_1_0->length()); 302 EXPECT_EQ(1, block_1_0->length());
301 303
302 // Verify that block_1_1 has two events. 304 // Verify that block_1_1 has two events.
303 EXPECT_EQ(2, block_1_1->length()); 305 EXPECT_EQ(2, block_1_1->length());
304 306
305 // Thread '2" should have one block.' 307 // Thread '2" should have one block.'
306 EXPECT_EQ(1, thread_2->NumBlocks()); 308 EXPECT_EQ(1, thread_2->NumBlocks());
307 EXPECT_EQ(thread_2->At(0), block_2_0); 309 EXPECT_EQ(thread_2->At(0), block_2_0);
308 // Verify that block_2_0 has six events. 310 // Verify that block_2_0 has six events.
309 EXPECT_EQ(6, block_2_0->length()); 311 EXPECT_EQ(6, block_2_0->length());
310 } 312 }
311 313
312 } // namespace dart 314 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/os_thread_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698