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

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

Issue 25909002: Sampling profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « runtime/vm/profiler_macos.cc ('k') | runtime/vm/profiler_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "platform/assert.h"
6
7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h"
9 #include "vm/globals.h"
10 #include "vm/profiler.h"
11 #include "vm/unit_test.h"
12
13 namespace dart {
14
15 class ProfileSampleBufferTestHelper {
16 public:
17 static intptr_t IterateCount(const SampleBuffer& sample_buffer) {
18 intptr_t c = 0;
19 for (Sample* i = sample_buffer.FirstSample();
20 i != sample_buffer.LastSample();
21 i = sample_buffer.NextSample(i)) {
22 c++;
23 }
24 return c;
25 }
26
27
28 static intptr_t IterateSumPC(const SampleBuffer& sample_buffer) {
29 intptr_t c = 0;
30 for (Sample* i = sample_buffer.FirstSample();
31 i != sample_buffer.LastSample();
32 i = sample_buffer.NextSample(i)) {
33 c += i->pcs[0];
34 }
35 return c;
36 }
37 };
38
39
40 TEST_CASE(ProfilerSampleBufferWrapTest) {
41 SampleBuffer* sample_buffer = new SampleBuffer(3);
42 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateSumPC(*sample_buffer));
43 Sample* s;
44 s = sample_buffer->ReserveSample();
45 s->pcs[0] = 2;
46 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateSumPC(*sample_buffer));
47 s = sample_buffer->ReserveSample();
48 s->pcs[0] = 4;
49 EXPECT_EQ(6, ProfileSampleBufferTestHelper::IterateSumPC(*sample_buffer));
50 s = sample_buffer->ReserveSample();
51 s->pcs[0] = 6;
52 EXPECT_EQ(10, ProfileSampleBufferTestHelper::IterateSumPC(*sample_buffer));
53 s = sample_buffer->ReserveSample();
54 s->pcs[0] = 8;
55 EXPECT_EQ(14, ProfileSampleBufferTestHelper::IterateSumPC(*sample_buffer));
56 delete sample_buffer;
57 }
58
59
60 TEST_CASE(ProfilerSampleBufferIterateTest) {
61 SampleBuffer* sample_buffer = new SampleBuffer(3);
62 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateCount(*sample_buffer));
63 sample_buffer->ReserveSample();
64 EXPECT_EQ(1, ProfileSampleBufferTestHelper::IterateCount(*sample_buffer));
65 sample_buffer->ReserveSample();
66 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateCount(*sample_buffer));
67 sample_buffer->ReserveSample();
68 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateCount(*sample_buffer));
69 sample_buffer->ReserveSample();
70 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateCount(*sample_buffer));
71 delete sample_buffer;
72 }
73
74 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler_macos.cc ('k') | runtime/vm/profiler_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698