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

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

Issue 1199473003: Add storage of class id and state bit to the profiler's Sample (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/profiler.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/profiler.h" 10 #include "vm/profiler.h"
(...skipping 25 matching lines...) Expand all
36 if (sample->isolate() != isolate) { 36 if (sample->isolate() != isolate) {
37 continue; 37 continue;
38 } 38 }
39 c += sample->At(0); 39 c += sample->At(0);
40 } 40 }
41 return c; 41 return c;
42 } 42 }
43 }; 43 };
44 44
45 45
46 TEST_CASE(ProfilerSampleBufferWrapTest) { 46 TEST_CASE(Profiler_SampleBufferWrapTest) {
47 SampleBuffer* sample_buffer = new SampleBuffer(3); 47 SampleBuffer* sample_buffer = new SampleBuffer(3);
48 Isolate* i = reinterpret_cast<Isolate*>(0x1); 48 Isolate* i = reinterpret_cast<Isolate*>(0x1);
49 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); 49 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer));
50 Sample* s; 50 Sample* s;
51 s = sample_buffer->ReserveSample(); 51 s = sample_buffer->ReserveSample();
52 s->Init(i, 0, 0); 52 s->Init(i, 0, 0);
53 s->SetAt(0, 2); 53 s->SetAt(0, 2);
54 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); 54 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer));
55 s = sample_buffer->ReserveSample(); 55 s = sample_buffer->ReserveSample();
56 s->Init(i, 0, 0); 56 s->Init(i, 0, 0);
57 s->SetAt(0, 4); 57 s->SetAt(0, 4);
58 EXPECT_EQ(6, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); 58 EXPECT_EQ(6, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer));
59 s = sample_buffer->ReserveSample(); 59 s = sample_buffer->ReserveSample();
60 s->Init(i, 0, 0); 60 s->Init(i, 0, 0);
61 s->SetAt(0, 6); 61 s->SetAt(0, 6);
62 EXPECT_EQ(12, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); 62 EXPECT_EQ(12, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer));
63 s = sample_buffer->ReserveSample(); 63 s = sample_buffer->ReserveSample();
64 s->Init(i, 0, 0); 64 s->Init(i, 0, 0);
65 s->SetAt(0, 8); 65 s->SetAt(0, 8);
66 EXPECT_EQ(18, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); 66 EXPECT_EQ(18, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer));
67 delete sample_buffer; 67 delete sample_buffer;
68 } 68 }
69 69
70 70
71 TEST_CASE(ProfilerSampleBufferIterateTest) { 71 TEST_CASE(Profiler_SampleBufferIterateTest) {
72 SampleBuffer* sample_buffer = new SampleBuffer(3); 72 SampleBuffer* sample_buffer = new SampleBuffer(3);
73 Isolate* i = reinterpret_cast<Isolate*>(0x1); 73 Isolate* i = reinterpret_cast<Isolate*>(0x1);
74 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); 74 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer));
75 Sample* s; 75 Sample* s;
76 s = sample_buffer->ReserveSample(); 76 s = sample_buffer->ReserveSample();
77 s->Init(i, 0, 0); 77 s->Init(i, 0, 0);
78 EXPECT_EQ(1, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); 78 EXPECT_EQ(1, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer));
79 s = sample_buffer->ReserveSample(); 79 s = sample_buffer->ReserveSample();
80 s->Init(i, 0, 0); 80 s->Init(i, 0, 0);
81 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); 81 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer));
82 s = sample_buffer->ReserveSample(); 82 s = sample_buffer->ReserveSample();
83 s->Init(i, 0, 0); 83 s->Init(i, 0, 0);
84 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); 84 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer));
85 s = sample_buffer->ReserveSample(); 85 s = sample_buffer->ReserveSample();
86 s->Init(i, 0, 0); 86 s->Init(i, 0, 0);
87 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); 87 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer));
88 delete sample_buffer; 88 delete sample_buffer;
89 } 89 }
90 90
91
92 TEST_CASE(Profiler_AllocationSampleTest) {
93 Isolate* isolate = Isolate::Current();
94 SampleBuffer* sample_buffer = new SampleBuffer(3);
95 Sample* sample = sample_buffer->ReserveSample();
96 sample->Init(isolate, 0, 0);
97 sample->set_metadata(99);
98 sample->set_is_allocation_sample(true);
99 EXPECT_EQ(99, sample->allocation_cid());
100 delete sample_buffer;
101 }
102
91 } // namespace dart 103 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698