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

Side by Side Diff: vm/benchmark_test.cc

Issue 10280003: Set up a variable so that the compiler script can be imported using an import map. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | « vm/benchmark_test.h ('k') | vm/unit_test.h » ('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 #include "vm/benchmark_test.h"
6
7 #include "bin/file.h"
8
5 #include "platform/assert.h" 9 #include "platform/assert.h"
6 10
7 #include "vm/benchmark_test.h"
8 #include "vm/dart_api_impl.h" 11 #include "vm/dart_api_impl.h"
9 #include "vm/stack_frame.h" 12 #include "vm/stack_frame.h"
10 #include "vm/unit_test.h" 13 #include "vm/unit_test.h"
11 14
12 namespace dart { 15 namespace dart {
13 16
14 Benchmark* Benchmark::first_ = NULL; 17 Benchmark* Benchmark::first_ = NULL;
15 Benchmark* Benchmark::tail_ = NULL; 18 Benchmark* Benchmark::tail_ = NULL;
19 const char* Benchmark::executable_ = NULL;
16 20
17 void Benchmark::RunAll() { 21 void Benchmark::RunAll(const char* executable) {
22 SetExecutable(executable);
18 Benchmark* benchmark = first_; 23 Benchmark* benchmark = first_;
19 while (benchmark != NULL) { 24 while (benchmark != NULL) {
20 benchmark->RunBenchmark(); 25 benchmark->RunBenchmark();
21 benchmark = benchmark->next_; 26 benchmark = benchmark->next_;
22 } 27 }
23 } 28 }
24 29
25 30
26 // Compiler only implemented on IA32 and X64 now. 31 // Compiler only implemented on IA32 and X64 now.
27 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 32 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 Dart_Invoke(lib, 179 Dart_Invoke(lib,
175 Dart_NewString("benchmark"), 180 Dart_NewString("benchmark"),
176 1, 181 1,
177 args); 182 args);
178 timer.Stop(); 183 timer.Stop();
179 int64_t elapsed_time = timer.TotalElapsedTime(); 184 int64_t elapsed_time = timer.TotalElapsedTime();
180 benchmark->set_score(elapsed_time); 185 benchmark->set_score(elapsed_time);
181 } 186 }
182 187
183 188
184 #if 0
185 // 189 //
186 // Measure compile of all dart2js(compiler) functions. 190 // Measure compile of all dart2js(compiler) functions.
187 // 191 //
192 static char* ComputeDart2JSPath(const char* arg) {
193 char buffer[2048];
194 char* dart2js_path = strdup(File::GetCanonicalPath(arg));
195 const char* compiler_path = "%s%slib%scompiler%scompiler.dart";
196 char* ptr = strrchr(dart2js_path, File::PathSeparatorCharacter());
cshapiro 2012/05/01 21:41:52 Why not assert that the path separator is 1 charac
siva 2012/05/01 22:02:49 Done.
197 while (ptr != NULL) {
198 *ptr = '\0';
199 OS::SNPrint(buffer, 2048, compiler_path,
200 dart2js_path,
201 File::PathSeparator(),
202 File::PathSeparator(),
203 File::PathSeparator());
204 if (File::Exists(buffer)) {
205 break;
206 }
207 ptr = strrchr(dart2js_path, File::PathSeparatorCharacter());
cshapiro 2012/05/01 21:41:52 Same here.
siva 2012/05/01 22:02:49 Done.
208 }
209 if (ptr == NULL) {
210 free(dart2js_path);
211 dart2js_path = NULL;
212 }
213 return dart2js_path;
214 }
215
216
188 static void func(Dart_NativeArguments args) { 217 static void func(Dart_NativeArguments args) {
189 } 218 }
190 219
191 220
192 static Dart_NativeFunction NativeResolver(Dart_Handle name, 221 static Dart_NativeFunction NativeResolver(Dart_Handle name,
193 int arg_count) { 222 int arg_count) {
194 return &func; 223 return &func;
195 } 224 }
196 225
197 226
198 BENCHMARK(Dart2JSCompileAll) { 227 BENCHMARK(Dart2JSCompileAll) {
199 const char* kScriptChars = "#import('lib/compiler/compiler.dart');"; 228 char* dart_root = ComputeDart2JSPath(Benchmark::Executable());
229 Dart_Handle import_map;
230 if (dart_root != NULL) {
231 import_map = Dart_NewList(2);
232 Dart_ListSetAt(import_map, 0, Dart_NewString("DART_ROOT"));
233 Dart_ListSetAt(import_map, 1, Dart_NewString(dart_root));
234 } else {
235 import_map = Dart_NewList(0);
236 }
237 const char* kScriptChars =
238 "#import('${DART_ROOT}/lib/compiler/compiler.dart');";
200 Dart_Handle lib = TestCase::LoadTestScript( 239 Dart_Handle lib = TestCase::LoadTestScript(
201 kScriptChars, 240 kScriptChars,
202 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); 241 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver),
242 import_map);
203 EXPECT(!Dart_IsError(lib)); 243 EXPECT(!Dart_IsError(lib));
204 Timer timer(true, "Compile all of dart2js benchmark"); 244 Timer timer(true, "Compile all of dart2js benchmark");
205 timer.Start(); 245 timer.Start();
206 Dart_Handle result = Dart_CompileAll(); 246 Dart_Handle result = Dart_CompileAll();
207 EXPECT(!Dart_IsError(result)); 247 EXPECT(!Dart_IsError(result));
208 timer.Stop(); 248 timer.Stop();
209 int64_t elapsed_time = timer.TotalElapsedTime(); 249 int64_t elapsed_time = timer.TotalElapsedTime();
210 benchmark->set_score(elapsed_time); 250 benchmark->set_score(elapsed_time);
251 free(dart_root);
211 } 252 }
212 #endif
213 253
214 254
215 // 255 //
216 // Measure frame lookup during stack traversal. 256 // Measure frame lookup during stack traversal.
217 // 257 //
218 static void StackFrame_accessFrame(Dart_NativeArguments args) { 258 static void StackFrame_accessFrame(Dart_NativeArguments args) {
219 const int kNumIterations = 100; 259 const int kNumIterations = 100;
220 Dart_EnterScope(); 260 Dart_EnterScope();
221 Code& code = Code::Handle(); 261 Code& code = Code::Handle();
222 Timer timer(true, "LookupDartCode benchmark"); 262 Timer timer(true, "LookupDartCode benchmark");
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver)); 333 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver));
294 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest")); 334 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest"));
295 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); 335 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL);
296 EXPECT_VALID(result); 336 EXPECT_VALID(result);
297 int64_t elapsed_time = 0; 337 int64_t elapsed_time = 0;
298 EXPECT(!Dart_IsError(Dart_IntegerToInt64(result, &elapsed_time))); 338 EXPECT(!Dart_IsError(Dart_IntegerToInt64(result, &elapsed_time)));
299 benchmark->set_score(elapsed_time); 339 benchmark->set_score(elapsed_time);
300 } 340 }
301 341
302 } // namespace dart 342 } // namespace dart
OLDNEW
« no previous file with comments | « vm/benchmark_test.h ('k') | vm/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698