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

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

Issue 690103004: Move dart2js from sdk/lib/_internal/compiler to pkg/compiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | « pkg/pkg.status ('k') | runtime/vm/unit_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 #include "vm/benchmark_test.h" 5 #include "vm/benchmark_test.h"
6 6
7 #include "bin/builtin.h" 7 #include "bin/builtin.h"
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 222
223 // 223 //
224 // Measure compile of all dart2js(compiler) functions. 224 // Measure compile of all dart2js(compiler) functions.
225 // 225 //
226 static char* ComputeDart2JSPath(const char* arg) { 226 static char* ComputeDart2JSPath(const char* arg) {
227 char buffer[2048]; 227 char buffer[2048];
228 char* dart2js_path = strdup(File::GetCanonicalPath(arg)); 228 char* dart2js_path = strdup(File::GetCanonicalPath(arg));
229 const char* compiler_path = 229 const char* compiler_path =
230 "%s%ssdk%slib%s_internal%scompiler%scompiler.dart"; 230 "%s%spkg%scompiler%slib%scompiler.dart";
231 const char* path_separator = File::PathSeparator(); 231 const char* path_separator = File::PathSeparator();
232 ASSERT(path_separator != NULL && strlen(path_separator) == 1); 232 ASSERT(path_separator != NULL && strlen(path_separator) == 1);
233 char* ptr = strrchr(dart2js_path, *path_separator); 233 char* ptr = strrchr(dart2js_path, *path_separator);
234 while (ptr != NULL) { 234 while (ptr != NULL) {
235 *ptr = '\0'; 235 *ptr = '\0';
236 OS::SNPrint(buffer, 2048, compiler_path, 236 OS::SNPrint(buffer, 2048, compiler_path,
237 dart2js_path, 237 dart2js_path,
238 path_separator, 238 path_separator,
239 path_separator, 239 path_separator,
240 path_separator, 240 path_separator,
(...skipping 17 matching lines...) Expand all
258 258
259 259
260 static Dart_NativeFunction NativeResolver(Dart_Handle name, 260 static Dart_NativeFunction NativeResolver(Dart_Handle name,
261 int arg_count, 261 int arg_count,
262 bool* auto_setup_scope) { 262 bool* auto_setup_scope) {
263 ASSERT(auto_setup_scope != NULL); 263 ASSERT(auto_setup_scope != NULL);
264 *auto_setup_scope = false; 264 *auto_setup_scope = false;
265 return &func; 265 return &func;
266 } 266 }
267 267
268 static void SetupDart2JSPackagePath() {
269 Dart_Handle builtin_lib =
270 bin::Builtin::LoadAndCheckLibrary(bin::Builtin::kBuiltinLibrary);
271 DART_CHECK_VALID(builtin_lib);
272
273 bool worked = bin::DartUtils::SetOriginalWorkingDirectory();
274 EXPECT(worked);
275 char buffer[2048];
276 char* executable_path =
277 strdup(File::GetCanonicalPath(Benchmark::Executable()));
278 const char* packages_path = "%s%s..%spackages";
279 const char* path_separator = File::PathSeparator();
280 OS::SNPrint(buffer, 2048, packages_path,
281 executable_path, path_separator, path_separator);
282 bin::DartUtils::PrepareForScriptLoading(buffer, builtin_lib);
283 }
268 284
269 BENCHMARK(Dart2JSCompileAll) { 285 BENCHMARK(Dart2JSCompileAll) {
270 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); 286 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary);
271 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); 287 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary);
288 SetupDart2JSPackagePath();
272 char* dart_root = ComputeDart2JSPath(Benchmark::Executable()); 289 char* dart_root = ComputeDart2JSPath(Benchmark::Executable());
273 char* script = NULL; 290 char* script = NULL;
274 if (dart_root != NULL) { 291 if (dart_root != NULL) {
275 Isolate* isolate = Isolate::Current(); 292 Isolate* isolate = Isolate::Current();
276 HANDLESCOPE(isolate); 293 HANDLESCOPE(isolate);
277 const char* kFormatStr = 294 const char* kFormatStr =
278 "import '%s/sdk/lib/_internal/compiler/compiler.dart';"; 295 "import '%s/pkg/compiler/lib/compiler.dart';";
279 intptr_t len = OS::SNPrint(NULL, 0, kFormatStr, dart_root) + 1; 296 intptr_t len = OS::SNPrint(NULL, 0, kFormatStr, dart_root) + 1;
280 script = reinterpret_cast<char*>(malloc(len)); 297 script = reinterpret_cast<char*>(malloc(len));
281 EXPECT(script != NULL); 298 EXPECT(script != NULL);
282 OS::SNPrint(script, len, kFormatStr, dart_root); 299 OS::SNPrint(script, len, kFormatStr, dart_root);
283 Dart_Handle lib = TestCase::LoadTestScript( 300 Dart_Handle lib = TestCase::LoadTestScript(
284 script, 301 script,
285 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); 302 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver));
286 EXPECT_VALID(lib); 303 EXPECT_VALID(lib);
287 } else { 304 } else {
288 Dart_Handle lib = TestCase::LoadTestScript( 305 Dart_Handle lib = TestCase::LoadTestScript(
289 "import 'sdk/lib/_internal/compiler/compiler.dart';", 306 "import 'pkg/compiler/lib/compiler.dart';",
290 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); 307 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver));
291 EXPECT_VALID(lib); 308 EXPECT_VALID(lib);
292 } 309 }
293 Timer timer(true, "Compile all of dart2js benchmark"); 310 Timer timer(true, "Compile all of dart2js benchmark");
294 timer.Start(); 311 timer.Start();
295 Dart_Handle result = Dart_CompileAll(); 312 Dart_Handle result = Dart_CompileAll();
296 EXPECT_VALID(result); 313 EXPECT_VALID(result);
297 timer.Stop(); 314 timer.Stop();
298 int64_t elapsed_time = timer.TotalElapsedTime(); 315 int64_t elapsed_time = timer.TotalElapsedTime();
299 benchmark->set_score(elapsed_time); 316 benchmark->set_score(elapsed_time);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); 585 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate);
569 reader.ReadObject(); 586 reader.ReadObject();
570 free(buffer); 587 free(buffer);
571 } 588 }
572 timer.Stop(); 589 timer.Stop();
573 int64_t elapsed_time = timer.TotalElapsedTime(); 590 int64_t elapsed_time = timer.TotalElapsedTime();
574 benchmark->set_score(elapsed_time); 591 benchmark->set_score(elapsed_time);
575 } 592 }
576 593
577 } // namespace dart 594 } // namespace dart
OLDNEW
« no previous file with comments | « pkg/pkg.status ('k') | runtime/vm/unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698