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

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

Issue 314383002: - Report CodeSize instead of runtime for benchmarks reporting snapshot sizes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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/run_vm_tests.cc ('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 22 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise
23 // it is initialized to NULL. 23 // it is initialized to NULL.
24 namespace bin { 24 namespace bin {
25 extern const uint8_t* snapshot_buffer; 25 extern const uint8_t* snapshot_buffer;
26 } 26 }
27 27
28 // The BENCHMARK macro is used for benchmarking a specific functionality 28 // The BENCHMARK macro is used for benchmarking a specific functionality
29 // of the VM 29 // of the VM
30 #define BENCHMARK(name) \ 30 #define BENCHMARK_HELPER(name, kind) \
31 void Dart_Benchmark##name(Benchmark* benchmark); \ 31 void Dart_Benchmark##name(Benchmark* benchmark); \
32 static Benchmark kRegister##name(Dart_Benchmark##name, #name); \ 32 static Benchmark kRegister##name(Dart_Benchmark##name, #name, kind); \
33 static void Dart_BenchmarkHelper##name(Benchmark* benchmark); \ 33 static void Dart_BenchmarkHelper##name(Benchmark* benchmark); \
34 void Dart_Benchmark##name(Benchmark* benchmark) { \ 34 void Dart_Benchmark##name(Benchmark* benchmark) { \
35 FLAG_heap_growth_space_ratio = 100; \ 35 FLAG_heap_growth_space_ratio = 100; \
36 BenchmarkIsolateScope __isolate__(benchmark); \ 36 BenchmarkIsolateScope __isolate__(benchmark); \
37 StackZone __zone__(benchmark->isolate()); \ 37 StackZone __zone__(benchmark->isolate()); \
38 HandleScope __hs__(benchmark->isolate()); \ 38 HandleScope __hs__(benchmark->isolate()); \
39 Dart_BenchmarkHelper##name(benchmark); \ 39 Dart_BenchmarkHelper##name(benchmark); \
40 } \ 40 } \
41 static void Dart_BenchmarkHelper##name(Benchmark* benchmark) 41 static void Dart_BenchmarkHelper##name(Benchmark* benchmark)
42 42
43 #define BENCHMARK(name) BENCHMARK_HELPER(name, "RunTime")
44
45 #define BENCHMARK_SIZE(name) BENCHMARK_HELPER(name, "CodeSize")
46
43 47
44 inline Dart_Handle NewString(const char* str) { 48 inline Dart_Handle NewString(const char* str) {
45 return Dart_NewStringFromCString(str); 49 return Dart_NewStringFromCString(str);
46 } 50 }
47 51
48 52
49 class Benchmark { 53 class Benchmark {
50 public: 54 public:
51 typedef void (RunEntry)(Benchmark* benchmark); 55 typedef void (RunEntry)(Benchmark* benchmark);
52 56
53 Benchmark(RunEntry* run, const char* name) : 57 Benchmark(RunEntry* run, const char* name, const char* score_kind) :
54 run_(run), 58 run_(run),
55 name_(name), 59 name_(name),
60 score_kind_(score_kind),
56 score_(0), 61 score_(0),
57 isolate_(NULL), 62 isolate_(NULL),
58 next_(NULL) { 63 next_(NULL) {
59 if (first_ == NULL) { 64 if (first_ == NULL) {
60 first_ = this; 65 first_ = this;
61 } else { 66 } else {
62 tail_->next_ = this; 67 tail_->next_ = this;
63 } 68 }
64 tail_ = this; 69 tail_ = this;
65 } 70 }
66 71
67 // Accessors. 72 // Accessors.
68 const char* name() const { return name_; } 73 const char* name() const { return name_; }
74 const char* score_kind() const { return score_kind_; }
69 void set_score(intptr_t value) { score_ = value; } 75 void set_score(intptr_t value) { score_ = value; }
70 intptr_t score() const { return score_; } 76 intptr_t score() const { return score_; }
71 Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); } 77 Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); }
72 78
73 Dart_Isolate CreateIsolate(const uint8_t* buffer) { 79 Dart_Isolate CreateIsolate(const uint8_t* buffer) {
74 char* err = NULL; 80 char* err = NULL;
75 isolate_ = Dart_CreateIsolate(NULL, NULL, buffer, NULL, &err); 81 isolate_ = Dart_CreateIsolate(NULL, NULL, buffer, NULL, &err);
76 EXPECT(isolate_ != NULL); 82 EXPECT(isolate_ != NULL);
77 free(err); 83 free(err);
78 return isolate_; 84 return isolate_;
79 } 85 }
80 86
81 void Run() { (*run_)(this); } 87 void Run() { (*run_)(this); }
82 void RunBenchmark(); 88 void RunBenchmark();
83 89
84 static void RunAll(const char* executable); 90 static void RunAll(const char* executable);
85 static void SetExecutable(const char* arg) { executable_ = arg; } 91 static void SetExecutable(const char* arg) { executable_ = arg; }
86 static const char* Executable() { return executable_; } 92 static const char* Executable() { return executable_; }
87 93
88 private: 94 private:
89 static Benchmark* first_; 95 static Benchmark* first_;
90 static Benchmark* tail_; 96 static Benchmark* tail_;
91 static const char* executable_; 97 static const char* executable_;
92 98
93 RunEntry* const run_; 99 RunEntry* const run_;
94 const char* name_; 100 const char* name_;
101 const char* score_kind_;
95 intptr_t score_; 102 intptr_t score_;
96 Dart_Isolate isolate_; 103 Dart_Isolate isolate_;
97 Benchmark* next_; 104 Benchmark* next_;
98 105
99 DISALLOW_COPY_AND_ASSIGN(Benchmark); 106 DISALLOW_COPY_AND_ASSIGN(Benchmark);
100 }; 107 };
101 108
102 109
103 class BenchmarkIsolateScope { 110 class BenchmarkIsolateScope {
104 public: 111 public:
(...skipping 11 matching lines...) Expand all
116 123
117 private: 124 private:
118 Benchmark* benchmark_; 125 Benchmark* benchmark_;
119 126
120 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope); 127 DISALLOW_COPY_AND_ASSIGN(BenchmarkIsolateScope);
121 }; 128 };
122 129
123 } // namespace dart 130 } // namespace dart
124 131
125 #endif // VM_BENCHMARK_TEST_H_ 132 #endif // VM_BENCHMARK_TEST_H_
OLDNEW
« no previous file with comments | « runtime/bin/run_vm_tests.cc ('k') | runtime/vm/benchmark_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698