OLD | NEW |
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 RUNTIME_VM_BENCHMARK_TEST_H_ | 5 #ifndef RUNTIME_VM_BENCHMARK_TEST_H_ |
6 #define RUNTIME_VM_BENCHMARK_TEST_H_ | 6 #define RUNTIME_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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // isolate_snapshot_buffer points to a snapshot for an isolate if we link in a | 27 // isolate_snapshot_buffer points to a snapshot for an isolate if we link in a |
28 // snapshot otherwise it is initialized to NULL. | 28 // snapshot otherwise it is initialized to NULL. |
29 extern const uint8_t* isolate_snapshot_buffer; | 29 extern const uint8_t* isolate_snapshot_buffer; |
30 } | 30 } |
31 | 31 |
32 // The BENCHMARK macros are used for benchmarking a specific functionality | 32 // The BENCHMARK macros are used for benchmarking a specific functionality |
33 // of the VM. | 33 // of the VM. |
34 #define BENCHMARK_HELPER(name, kind) \ | 34 #define BENCHMARK_HELPER(name, kind) \ |
35 void Dart_Benchmark##name(Benchmark* benchmark); \ | 35 void Dart_Benchmark##name(Benchmark* benchmark); \ |
36 static Benchmark kRegister##name(Dart_Benchmark##name, #name, kind); \ | 36 static Benchmark kRegister##name(Dart_Benchmark##name, #name, kind); \ |
37 static void Dart_BenchmarkHelper##name(Benchmark* benchmark, Thread* thread);\ | 37 static void Dart_BenchmarkHelper##name(Benchmark* benchmark, \ |
| 38 Thread* thread); \ |
38 void Dart_Benchmark##name(Benchmark* benchmark) { \ | 39 void Dart_Benchmark##name(Benchmark* benchmark) { \ |
39 FLAG_old_gen_growth_space_ratio = 100; \ | 40 FLAG_old_gen_growth_space_ratio = 100; \ |
40 BenchmarkIsolateScope __isolate__(benchmark); \ | 41 BenchmarkIsolateScope __isolate__(benchmark); \ |
41 Thread* __thread__ = Thread::Current(); \ | 42 Thread* __thread__ = Thread::Current(); \ |
42 ASSERT(__thread__->isolate() == benchmark->isolate()); \ | 43 ASSERT(__thread__->isolate() == benchmark->isolate()); \ |
43 StackZone __zone__(__thread__); \ | 44 StackZone __zone__(__thread__); \ |
44 HandleScope __hs__(__thread__); \ | 45 HandleScope __hs__(__thread__); \ |
45 Dart_BenchmarkHelper##name(benchmark, __thread__); \ | 46 Dart_BenchmarkHelper##name(benchmark, __thread__); \ |
46 } \ | 47 } \ |
47 static void Dart_BenchmarkHelper##name(Benchmark* benchmark, Thread* thread) | 48 static void Dart_BenchmarkHelper##name(Benchmark* benchmark, Thread* thread) |
48 | 49 |
49 #define BENCHMARK(name) BENCHMARK_HELPER(name, "RunTime") | 50 #define BENCHMARK(name) BENCHMARK_HELPER(name, "RunTime") |
50 #define BENCHMARK_SIZE(name) BENCHMARK_HELPER(name, "CodeSize") | 51 #define BENCHMARK_SIZE(name) BENCHMARK_HELPER(name, "CodeSize") |
51 #define BENCHMARK_MEMORY(name) BENCHMARK_HELPER(name, "MemoryUse") | 52 #define BENCHMARK_MEMORY(name) BENCHMARK_HELPER(name, "MemoryUse") |
52 | 53 |
53 inline Dart_Handle NewString(const char* str) { | 54 inline Dart_Handle NewString(const char* str) { |
54 return Dart_NewStringFromCString(str); | 55 return Dart_NewStringFromCString(str); |
55 } | 56 } |
56 | 57 |
57 | 58 |
58 class Benchmark { | 59 class Benchmark { |
59 public: | 60 public: |
60 typedef void (RunEntry)(Benchmark* benchmark); | 61 typedef void(RunEntry)(Benchmark* benchmark); |
61 | 62 |
62 Benchmark(RunEntry* run, const char* name, const char* score_kind) : | 63 Benchmark(RunEntry* run, const char* name, const char* score_kind) |
63 run_(run), | 64 : run_(run), |
64 name_(name), | 65 name_(name), |
65 score_kind_(score_kind), | 66 score_kind_(score_kind), |
66 score_(0), | 67 score_(0), |
67 isolate_(NULL), | 68 isolate_(NULL), |
68 next_(NULL) { | 69 next_(NULL) { |
69 if (first_ == NULL) { | 70 if (first_ == NULL) { |
70 first_ = this; | 71 first_ = this; |
71 } else { | 72 } else { |
72 tail_->next_ = this; | 73 tail_->next_ = this; |
73 } | 74 } |
74 tail_ = this; | 75 tail_ = this; |
75 } | 76 } |
76 | 77 |
77 // Accessors. | 78 // Accessors. |
78 const char* name() const { return name_; } | 79 const char* name() const { return name_; } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 123 |
123 private: | 124 private: |
124 Benchmark* benchmark_; | 125 Benchmark* benchmark_; |
125 | 126 |
126 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope); | 127 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope); |
127 }; | 128 }; |
128 | 129 |
129 } // namespace dart | 130 } // namespace dart |
130 | 131 |
131 #endif // RUNTIME_VM_BENCHMARK_TEST_H_ | 132 #endif // RUNTIME_VM_BENCHMARK_TEST_H_ |
OLD | NEW |