OLD | NEW |
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" |
11 #include "vm/unit_test.h" | 11 #include "vm/unit_test.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 class ProfileSampleBufferTestHelper { | 15 class ProfileSampleBufferTestHelper { |
16 public: | 16 public: |
17 static intptr_t IterateCount(const Isolate* isolate, | 17 static intptr_t IterateCount(const Isolate* isolate, |
18 const SampleBuffer& sample_buffer) { | 18 const SampleBuffer& sample_buffer) { |
19 intptr_t c = 0; | 19 intptr_t c = 0; |
20 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) { | 20 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) { |
21 Sample* sample = sample_buffer.GetSample(i); | 21 Sample sample = sample_buffer.GetSample(i); |
22 if (sample->isolate != isolate) { | 22 if (sample.isolate != isolate) { |
23 continue; | 23 continue; |
24 } | 24 } |
25 c++; | 25 c++; |
26 } | 26 } |
27 return c; | 27 return c; |
28 } | 28 } |
29 | 29 |
30 | 30 |
31 static intptr_t IterateSumPC(const Isolate* isolate, | 31 static intptr_t IterateSumPC(const Isolate* isolate, |
32 const SampleBuffer& sample_buffer) { | 32 const SampleBuffer& sample_buffer) { |
33 intptr_t c = 0; | 33 intptr_t c = 0; |
34 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) { | 34 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) { |
35 Sample* sample = sample_buffer.GetSample(i); | 35 Sample sample = sample_buffer.GetSample(i); |
36 if (sample->isolate != isolate) { | 36 if (sample.isolate != isolate) { |
37 continue; | 37 continue; |
38 } | 38 } |
39 c += sample->pcs[0]; | 39 c += sample.pcs[0]; |
40 } | 40 } |
41 return c; | 41 return c; |
42 } | 42 } |
43 }; | 43 }; |
44 | 44 |
45 | 45 |
46 TEST_CASE(ProfilerSampleBufferWrapTest) { | 46 TEST_CASE(ProfilerSampleBufferWrapTest) { |
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)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 s = sample_buffer->ReserveSample(); | 82 s = sample_buffer->ReserveSample(); |
83 s->isolate = i; | 83 s->isolate = i; |
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->isolate = i; | 86 s->isolate = i; |
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 } // namespace dart | 91 } // namespace dart |
OLD | NEW |