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

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

Issue 131853007: Add flag to control number of stack frames collected by profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« runtime/vm/profiler.cc ('K') | « 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"
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 Sample* sample = Sample::Allocate();
20 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) { 21 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) {
21 Sample sample = sample_buffer.GetSample(i); 22 sample_buffer.CopySample(i, sample);
22 if (sample.isolate != isolate) { 23 if (sample->isolate != isolate) {
23 continue; 24 continue;
24 } 25 }
25 c++; 26 c++;
26 } 27 }
28 free(sample);
27 return c; 29 return c;
28 } 30 }
29 31
30 32
31 static intptr_t IterateSumPC(const Isolate* isolate, 33 static intptr_t IterateSumPC(const Isolate* isolate,
32 const SampleBuffer& sample_buffer) { 34 const SampleBuffer& sample_buffer) {
33 intptr_t c = 0; 35 intptr_t c = 0;
36 Sample* sample = Sample::Allocate();
34 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) { 37 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) {
35 Sample sample = sample_buffer.GetSample(i); 38 sample_buffer.CopySample(i, sample);
36 if (sample.isolate != isolate) { 39 if (sample->isolate != isolate) {
37 continue; 40 continue;
38 } 41 }
39 c += sample.pcs[0]; 42 c += sample->pcs[0];
40 } 43 }
44 free(sample);
41 return c; 45 return c;
42 } 46 }
43 }; 47 };
44 48
45 49
46 TEST_CASE(ProfilerSampleBufferWrapTest) { 50 TEST_CASE(ProfilerSampleBufferWrapTest) {
47 SampleBuffer* sample_buffer = new SampleBuffer(3); 51 SampleBuffer* sample_buffer = new SampleBuffer(3);
48 Isolate* i = reinterpret_cast<Isolate*>(0x1); 52 Isolate* i = reinterpret_cast<Isolate*>(0x1);
49 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); 53 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer));
50 Sample* s; 54 Sample* s;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 s = sample_buffer->ReserveSample(); 86 s = sample_buffer->ReserveSample();
83 s->isolate = i; 87 s->isolate = i;
84 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); 88 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer));
85 s = sample_buffer->ReserveSample(); 89 s = sample_buffer->ReserveSample();
86 s->isolate = i; 90 s->isolate = i;
87 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); 91 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer));
88 delete sample_buffer; 92 delete sample_buffer;
89 } 93 }
90 94
91 } // namespace dart 95 } // namespace dart
OLDNEW
« runtime/vm/profiler.cc ('K') | « runtime/vm/profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698