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

Side by Side Diff: runtime/vm/benchmark_test.h

Issue 14988005: Fixed bug in vm/benchmark_test.h (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
« no previous file with comments | « no previous file | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #ifndef VM_BENCHMARK_TEST_H_ 5 #ifndef VM_BENCHMARK_TEST_H_
6 #define VM_BENCHMARK_TEST_H_ 6 #define VM_BENCHMARK_TEST_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "vm/dart.h" 10 #include "vm/dart.h"
11 #include "vm/globals.h" 11 #include "vm/globals.h"
12 #include "vm/heap.h" 12 #include "vm/heap.h"
13 #include "vm/isolate.h" 13 #include "vm/isolate.h"
14 #include "vm/object.h" 14 #include "vm/object.h"
15 #include "vm/zone.h" 15 #include "vm/zone.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 DECLARE_FLAG(int, code_heap_size); 19 DECLARE_FLAG(int, code_heap_size);
20 DECLARE_FLAG(int, heap_growth_space_ratio); 20 DECLARE_FLAG(int, heap_growth_space_ratio);
21 21
22 // The BENCHMARK macro is used for benchmarking a specific functionality 22 // The BENCHMARK macro is used for benchmarking a specific functionality
23 // of the VM 23 // of the VM
24 #define BENCHMARK(name) \ 24 #define BENCHMARK(name) \
25 void Dart_Benchmark##name(Benchmark* benchmark); \ 25 void Dart_Benchmark##name(Benchmark* benchmark); \
26 static const Benchmark kRegister##name(Dart_Benchmark##name, #name); \ 26 static Benchmark kRegister##name(Dart_Benchmark##name, #name); \
27 static void Dart_BenchmarkHelper##name(Benchmark* benchmark); \ 27 static void Dart_BenchmarkHelper##name(Benchmark* benchmark); \
28 void Dart_Benchmark##name(Benchmark* benchmark) { \ 28 void Dart_Benchmark##name(Benchmark* benchmark) { \
29 FLAG_heap_growth_space_ratio = 100; \ 29 FLAG_heap_growth_space_ratio = 100; \
30 BenchmarkIsolateScope __isolate__(benchmark); \ 30 BenchmarkIsolateScope __isolate__(benchmark); \
31 StackZone __zone__(benchmark->isolate()); \ 31 StackZone __zone__(benchmark->isolate()); \
32 HandleScope __hs__(benchmark->isolate()); \ 32 HandleScope __hs__(benchmark->isolate()); \
33 Dart_BenchmarkHelper##name(benchmark); \ 33 Dart_BenchmarkHelper##name(benchmark); \
34 } \ 34 } \
35 static void Dart_BenchmarkHelper##name(Benchmark* benchmark) 35 static void Dart_BenchmarkHelper##name(Benchmark* benchmark)
36 36
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 static const char* Executable() { return executable_; } 80 static const char* Executable() { return executable_; }
81 81
82 private: 82 private:
83 static Benchmark* first_; 83 static Benchmark* first_;
84 static Benchmark* tail_; 84 static Benchmark* tail_;
85 static const char* executable_; 85 static const char* executable_;
86 86
87 RunEntry* const run_; 87 RunEntry* const run_;
88 const char* name_; 88 const char* name_;
89 intptr_t score_; 89 intptr_t score_;
90 Dart_Isolate isolate_; 90 Dart_Isolate isolate_;
Ivan Posva 2013/05/06 14:44:31 isolate_ is just the first victim, but there are m
91 Benchmark* next_; 91 Benchmark* next_;
92 92
93 DISALLOW_COPY_AND_ASSIGN(Benchmark); 93 DISALLOW_COPY_AND_ASSIGN(Benchmark);
94 }; 94 };
95 95
96 96
97 class BenchmarkIsolateScope { 97 class BenchmarkIsolateScope {
98 public: 98 public:
99 explicit BenchmarkIsolateScope(Benchmark* benchmark) : benchmark_(benchmark) { 99 explicit BenchmarkIsolateScope(Benchmark* benchmark) : benchmark_(benchmark) {
100 benchmark_->CreateIsolate(NULL); 100 benchmark_->CreateIsolate(NULL);
101 Dart_EnterScope(); // Create a Dart API scope for unit benchmarks. 101 Dart_EnterScope(); // Create a Dart API scope for unit benchmarks.
102 } 102 }
103 ~BenchmarkIsolateScope() { 103 ~BenchmarkIsolateScope() {
104 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. 104 Dart_ExitScope(); // Exit the Dart API scope created for unit tests.
105 ASSERT(benchmark_->isolate() == Isolate::Current()); 105 ASSERT(benchmark_->isolate() == Isolate::Current());
106 Dart_ShutdownIsolate(); 106 Dart_ShutdownIsolate();
107 benchmark_ = NULL; 107 benchmark_ = NULL;
108 } 108 }
109 Benchmark* benchmark() const { return benchmark_; } 109 Benchmark* benchmark() const { return benchmark_; }
110 110
111 private: 111 private:
112 Benchmark* benchmark_; 112 Benchmark* benchmark_;
113 113
114 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope); 114 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope);
115 }; 115 };
116 116
117 } // namespace dart 117 } // namespace dart
118 118
119 #endif // VM_BENCHMARK_TEST_H_ 119 #endif // VM_BENCHMARK_TEST_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698