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

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

Issue 15640002: Fix runnning of vm benchmarks on golem. (Closed) Base URL: http://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 | « runtime/bin/bin.gypi ('k') | runtime/vm/benchmark_test.cc » ('j') | 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 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise
23 // it is initialized to NULL.
24 namespace bin {
25 extern const uint8_t* snapshot_buffer;
26 }
27
22 // The BENCHMARK macro is used for benchmarking a specific functionality 28 // The BENCHMARK macro is used for benchmarking a specific functionality
23 // of the VM 29 // of the VM
24 #define BENCHMARK(name) \ 30 #define BENCHMARK(name) \
25 void Dart_Benchmark##name(Benchmark* benchmark); \ 31 void Dart_Benchmark##name(Benchmark* benchmark); \
26 static Benchmark kRegister##name(Dart_Benchmark##name, #name); \ 32 static Benchmark kRegister##name(Dart_Benchmark##name, #name); \
27 static void Dart_BenchmarkHelper##name(Benchmark* benchmark); \ 33 static void Dart_BenchmarkHelper##name(Benchmark* benchmark); \
28 void Dart_Benchmark##name(Benchmark* benchmark) { \ 34 void Dart_Benchmark##name(Benchmark* benchmark) { \
29 FLAG_heap_growth_space_ratio = 100; \ 35 FLAG_heap_growth_space_ratio = 100; \
30 BenchmarkIsolateScope __isolate__(benchmark); \ 36 BenchmarkIsolateScope __isolate__(benchmark); \
31 StackZone __zone__(benchmark->isolate()); \ 37 StackZone __zone__(benchmark->isolate()); \
(...skipping 25 matching lines...) Expand all
57 } 63 }
58 tail_ = this; 64 tail_ = this;
59 } 65 }
60 66
61 // Accessors. 67 // Accessors.
62 const char* name() const { return name_; } 68 const char* name() const { return name_; }
63 void set_score(intptr_t value) { score_ = value; } 69 void set_score(intptr_t value) { score_ = value; }
64 intptr_t score() const { return score_; } 70 intptr_t score() const { return score_; }
65 Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); } 71 Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); }
66 72
67 Dart_Isolate CreateIsolate(uint8_t* buffer) { 73 Dart_Isolate CreateIsolate(const uint8_t* buffer) {
68 char* err = NULL; 74 char* err = NULL;
69 isolate_ = Dart_CreateIsolate(NULL, NULL, buffer, NULL, &err); 75 isolate_ = Dart_CreateIsolate(NULL, NULL, buffer, NULL, &err);
70 EXPECT(isolate_ != NULL); 76 EXPECT(isolate_ != NULL);
71 free(err); 77 free(err);
72 return isolate_; 78 return isolate_;
73 } 79 }
74 80
75 void Run() { (*run_)(this); } 81 void Run() { (*run_)(this); }
76 void RunBenchmark(); 82 void RunBenchmark();
77 83
(...skipping 12 matching lines...) Expand all
90 Dart_Isolate isolate_; 96 Dart_Isolate isolate_;
91 Benchmark* next_; 97 Benchmark* next_;
92 98
93 DISALLOW_COPY_AND_ASSIGN(Benchmark); 99 DISALLOW_COPY_AND_ASSIGN(Benchmark);
94 }; 100 };
95 101
96 102
97 class BenchmarkIsolateScope { 103 class BenchmarkIsolateScope {
98 public: 104 public:
99 explicit BenchmarkIsolateScope(Benchmark* benchmark) : benchmark_(benchmark) { 105 explicit BenchmarkIsolateScope(Benchmark* benchmark) : benchmark_(benchmark) {
100 benchmark_->CreateIsolate(NULL); 106 benchmark_->CreateIsolate(bin::snapshot_buffer);
101 Dart_EnterScope(); // Create a Dart API scope for unit benchmarks. 107 Dart_EnterScope(); // Create a Dart API scope for unit benchmarks.
102 } 108 }
103 ~BenchmarkIsolateScope() { 109 ~BenchmarkIsolateScope() {
104 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. 110 Dart_ExitScope(); // Exit the Dart API scope created for unit tests.
105 ASSERT(benchmark_->isolate() == Isolate::Current()); 111 ASSERT(benchmark_->isolate() == Isolate::Current());
106 Dart_ShutdownIsolate(); 112 Dart_ShutdownIsolate();
107 benchmark_ = NULL; 113 benchmark_ = NULL;
108 } 114 }
109 Benchmark* benchmark() const { return benchmark_; } 115 Benchmark* benchmark() const { return benchmark_; }
110 116
111 private: 117 private:
112 Benchmark* benchmark_; 118 Benchmark* benchmark_;
113 119
114 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope); 120 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope);
115 }; 121 };
116 122
117 } // namespace dart 123 } // namespace dart
118 124
119 #endif // VM_BENCHMARK_TEST_H_ 125 #endif // VM_BENCHMARK_TEST_H_
OLDNEW
« no previous file with comments | « runtime/bin/bin.gypi ('k') | runtime/vm/benchmark_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698