| 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 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, old_gen_growth_space_ratio); | 20 DECLARE_FLAG(int, old_gen_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 { | 22 namespace bin { |
| 25 extern const uint8_t* snapshot_buffer; | 23 // vm_isolate_snapshot_buffer points to a snapshot for the vm isolate if we |
| 24 // link in a snapshot otherwise it is initialized to NULL. |
| 25 extern const uint8_t* vm_isolate_snapshot_buffer; |
| 26 |
| 27 // isolate_snapshot_buffer points to a snapshot for an isolate if we link in a |
| 28 // snapshot otherwise it is initialized to NULL. |
| 29 extern const uint8_t* isolate_snapshot_buffer; |
| 26 } | 30 } |
| 27 | 31 |
| 28 // The BENCHMARK macros are used for benchmarking a specific functionality | 32 // The BENCHMARK macros are used for benchmarking a specific functionality |
| 29 // of the VM. | 33 // of the VM. |
| 30 #define BENCHMARK_HELPER(name, kind) \ | 34 #define BENCHMARK_HELPER(name, kind) \ |
| 31 void Dart_Benchmark##name(Benchmark* benchmark); \ | 35 void Dart_Benchmark##name(Benchmark* benchmark); \ |
| 32 static Benchmark kRegister##name(Dart_Benchmark##name, #name, kind); \ | 36 static Benchmark kRegister##name(Dart_Benchmark##name, #name, kind); \ |
| 33 static void Dart_BenchmarkHelper##name(Benchmark* benchmark); \ | 37 static void Dart_BenchmarkHelper##name(Benchmark* benchmark); \ |
| 34 void Dart_Benchmark##name(Benchmark* benchmark) { \ | 38 void Dart_Benchmark##name(Benchmark* benchmark) { \ |
| 35 FLAG_old_gen_growth_space_ratio = 100; \ | 39 FLAG_old_gen_growth_space_ratio = 100; \ |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 Dart_Isolate isolate_; | 106 Dart_Isolate isolate_; |
| 103 Benchmark* next_; | 107 Benchmark* next_; |
| 104 | 108 |
| 105 DISALLOW_COPY_AND_ASSIGN(Benchmark); | 109 DISALLOW_COPY_AND_ASSIGN(Benchmark); |
| 106 }; | 110 }; |
| 107 | 111 |
| 108 | 112 |
| 109 class BenchmarkIsolateScope { | 113 class BenchmarkIsolateScope { |
| 110 public: | 114 public: |
| 111 explicit BenchmarkIsolateScope(Benchmark* benchmark) : benchmark_(benchmark) { | 115 explicit BenchmarkIsolateScope(Benchmark* benchmark) : benchmark_(benchmark) { |
| 112 benchmark_->CreateIsolate(bin::snapshot_buffer); | 116 benchmark_->CreateIsolate(bin::isolate_snapshot_buffer); |
| 113 Dart_EnterScope(); // Create a Dart API scope for unit benchmarks. | 117 Dart_EnterScope(); // Create a Dart API scope for unit benchmarks. |
| 114 } | 118 } |
| 115 ~BenchmarkIsolateScope() { | 119 ~BenchmarkIsolateScope() { |
| 116 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. | 120 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. |
| 117 ASSERT(benchmark_->isolate() == Isolate::Current()); | 121 ASSERT(benchmark_->isolate() == Isolate::Current()); |
| 118 Dart_ShutdownIsolate(); | 122 Dart_ShutdownIsolate(); |
| 119 benchmark_ = NULL; | 123 benchmark_ = NULL; |
| 120 } | 124 } |
| 121 Benchmark* benchmark() const { return benchmark_; } | 125 Benchmark* benchmark() const { return benchmark_; } |
| 122 | 126 |
| 123 private: | 127 private: |
| 124 Benchmark* benchmark_; | 128 Benchmark* benchmark_; |
| 125 | 129 |
| 126 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope); | 130 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope); |
| 127 }; | 131 }; |
| 128 | 132 |
| 129 } // namespace dart | 133 } // namespace dart |
| 130 | 134 |
| 131 #endif // VM_BENCHMARK_TEST_H_ | 135 #endif // VM_BENCHMARK_TEST_H_ |
| OLD | NEW |