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

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

Issue 1473403003: Move ApiLocalScope out of class ApiState into class Thread so that the API local handles and zone e… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review-patch Created 5 years 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
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/bootstrap.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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 timer.Stop(); 49 timer.Stop();
50 int64_t elapsed_time = timer.TotalElapsedTime(); 50 int64_t elapsed_time = timer.TotalElapsedTime();
51 benchmark->set_score(elapsed_time); 51 benchmark->set_score(elapsed_time);
52 } 52 }
53 53
54 54
55 BENCHMARK(CorelibCompilerStats) { 55 BENCHMARK(CorelibCompilerStats) {
56 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); 56 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary);
57 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); 57 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary);
58 CompilerStats* stats = Isolate::Current()->compiler_stats(); 58 CompilerStats* stats = thread->isolate()->compiler_stats();
59 ASSERT(stats != NULL); 59 ASSERT(stats != NULL);
60 stats->EnableBenchmark(); 60 stats->EnableBenchmark();
61 Timer timer(true, "Compiler stats compiling all of Core lib"); 61 Timer timer(true, "Compiler stats compiling all of Core lib");
62 timer.Start(); 62 timer.Start();
63 const Error& error = Error::Handle(Library::CompileAll()); 63 const Error& error = Error::Handle(Library::CompileAll());
64 if (!error.IsNull()) { 64 if (!error.IsNull()) {
65 OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", 65 OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s",
66 error.ToErrorCString()); 66 error.ToErrorCString());
67 } 67 }
68 timer.Stop(); 68 timer.Stop();
69 int64_t elapsed_time = timer.TotalElapsedTime(); 69 int64_t elapsed_time = timer.TotalElapsedTime();
70 benchmark->set_score(elapsed_time); 70 benchmark->set_score(elapsed_time);
71 } 71 }
72 72
73 73
74 // 74 //
75 // Measure creation of core isolate from a snapshot. 75 // Measure creation of core isolate from a snapshot.
76 // 76 //
77 BENCHMARK(CorelibIsolateStartup) { 77 BENCHMARK(CorelibIsolateStartup) {
78 const int kNumIterations = 1000; 78 const int kNumIterations = 1000;
79 Timer timer(true, "CorelibIsolateStartup"); 79 Timer timer(true, "CorelibIsolateStartup");
80 Isolate* isolate = Isolate::Current(); 80 Isolate* isolate = thread->isolate();
81 Thread::ExitIsolate(); 81 Thread::ExitIsolate();
82 for (int i = 0; i < kNumIterations; i++) { 82 for (int i = 0; i < kNumIterations; i++) {
83 timer.Start(); 83 timer.Start();
84 TestCase::CreateTestIsolate(); 84 TestCase::CreateTestIsolate();
85 timer.Stop(); 85 timer.Stop();
86 Dart_ShutdownIsolate(); 86 Dart_ShutdownIsolate();
87 } 87 }
88 benchmark->set_score(timer.TotalElapsedTime() / kNumIterations); 88 benchmark->set_score(timer.TotalElapsedTime() / kNumIterations);
89 Thread::EnterIsolate(isolate); 89 Thread::EnterIsolate(isolate);
90 } 90 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 Dart_Handle lib = TestCase::LoadTestScript( 409 Dart_Handle lib = TestCase::LoadTestScript(
410 script, 410 script,
411 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); 411 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver));
412 EXPECT_VALID(lib); 412 EXPECT_VALID(lib);
413 } else { 413 } else {
414 Dart_Handle lib = TestCase::LoadTestScript( 414 Dart_Handle lib = TestCase::LoadTestScript(
415 "import 'pkg/compiler/lib/compiler.dart';", 415 "import 'pkg/compiler/lib/compiler.dart';",
416 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); 416 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver));
417 EXPECT_VALID(lib); 417 EXPECT_VALID(lib);
418 } 418 }
419 CompilerStats* stats = Isolate::Current()->compiler_stats(); 419 CompilerStats* stats = thread->isolate()->compiler_stats();
420 ASSERT(stats != NULL); 420 ASSERT(stats != NULL);
421 stats->EnableBenchmark(); 421 stats->EnableBenchmark();
422 Timer timer(true, "Compile all of dart2js benchmark"); 422 Timer timer(true, "Compile all of dart2js benchmark");
423 timer.Start(); 423 timer.Start();
424 Dart_Handle result = Dart_CompileAll(); 424 Dart_Handle result = Dart_CompileAll();
425 EXPECT_VALID(result); 425 EXPECT_VALID(result);
426 timer.Stop(); 426 timer.Stop();
427 int64_t elapsed_time = timer.TotalElapsedTime(); 427 int64_t elapsed_time = timer.TotalElapsedTime();
428 benchmark->set_score(elapsed_time); 428 benchmark->set_score(elapsed_time);
429 free(dart_root); 429 free(dart_root);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 "import 'dart:mirrors';\n" 538 "import 'dart:mirrors';\n"
539 "import 'dart:typed_data';\n" 539 "import 'dart:typed_data';\n"
540 "\n"; 540 "\n";
541 541
542 // Start an Isolate, load a script and create a full snapshot. 542 // Start an Isolate, load a script and create a full snapshot.
543 uint8_t* vm_isolate_snapshot_buffer; 543 uint8_t* vm_isolate_snapshot_buffer;
544 uint8_t* isolate_snapshot_buffer; 544 uint8_t* isolate_snapshot_buffer;
545 // Need to load the script into the dart: core library due to 545 // Need to load the script into the dart: core library due to
546 // the import of dart:_internal. 546 // the import of dart:_internal.
547 TestCase::LoadCoreTestScript(kScriptChars, NULL); 547 TestCase::LoadCoreTestScript(kScriptChars, NULL);
548 Api::CheckAndFinalizePendingClasses(Isolate::Current()); 548 Api::CheckAndFinalizePendingClasses(thread);
549 549
550 // Write snapshot with object content. 550 // Write snapshot with object content.
551 FullSnapshotWriter writer(&vm_isolate_snapshot_buffer, 551 FullSnapshotWriter writer(&vm_isolate_snapshot_buffer,
552 &isolate_snapshot_buffer, 552 &isolate_snapshot_buffer,
553 NULL, /* instructions_snapshot_buffer */ 553 NULL, /* instructions_snapshot_buffer */
554 &malloc_allocator, 554 &malloc_allocator,
555 false, /* snapshot_code */ 555 false, /* snapshot_code */
556 true /* vm_isolate_is_symbolic */); 556 true /* vm_isolate_is_symbolic */);
557 writer.WriteFullSnapshot(); 557 writer.WriteFullSnapshot();
558 const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer); 558 const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer);
(...skipping 16 matching lines...) Expand all
575 "import 'dart:_builtin';\n" 575 "import 'dart:_builtin';\n"
576 "import 'dart:io';\n" 576 "import 'dart:io';\n"
577 "\n"; 577 "\n";
578 578
579 // Start an Isolate, load a script and create a full snapshot. 579 // Start an Isolate, load a script and create a full snapshot.
580 uint8_t* vm_isolate_snapshot_buffer; 580 uint8_t* vm_isolate_snapshot_buffer;
581 uint8_t* isolate_snapshot_buffer; 581 uint8_t* isolate_snapshot_buffer;
582 // Need to load the script into the dart: core library due to 582 // Need to load the script into the dart: core library due to
583 // the import of dart:_internal. 583 // the import of dart:_internal.
584 TestCase::LoadCoreTestScript(kScriptChars, NULL); 584 TestCase::LoadCoreTestScript(kScriptChars, NULL);
585 Api::CheckAndFinalizePendingClasses(Isolate::Current()); 585 Api::CheckAndFinalizePendingClasses(thread);
586 586
587 // Write snapshot with object content. 587 // Write snapshot with object content.
588 FullSnapshotWriter writer(&vm_isolate_snapshot_buffer, 588 FullSnapshotWriter writer(&vm_isolate_snapshot_buffer,
589 &isolate_snapshot_buffer, 589 &isolate_snapshot_buffer,
590 NULL, /* instructions_snapshot_buffer */ 590 NULL, /* instructions_snapshot_buffer */
591 &malloc_allocator, 591 &malloc_allocator,
592 false, /* snapshot_code */ 592 false, /* snapshot_code */
593 true /* vm_isolate_is_symbolic */); 593 true /* vm_isolate_is_symbolic */);
594 writer.WriteFullSnapshot(); 594 writer.WriteFullSnapshot();
595 const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer); 595 const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer);
(...skipping 20 matching lines...) Expand all
616 benchmark->set_score(elapsed_time); 616 benchmark->set_score(elapsed_time);
617 } 617 }
618 618
619 619
620 BENCHMARK(EnterExitIsolate) { 620 BENCHMARK(EnterExitIsolate) {
621 const char* kScriptChars = 621 const char* kScriptChars =
622 "import 'dart:core';\n" 622 "import 'dart:core';\n"
623 "\n"; 623 "\n";
624 const intptr_t kLoopCount = 1000000; 624 const intptr_t kLoopCount = 1000000;
625 TestCase::LoadTestScript(kScriptChars, NULL); 625 TestCase::LoadTestScript(kScriptChars, NULL);
626 Api::CheckAndFinalizePendingClasses(Isolate::Current()); 626 Api::CheckAndFinalizePendingClasses(thread);
627 Dart_Isolate isolate = Dart_CurrentIsolate(); 627 Dart_Isolate isolate = Dart_CurrentIsolate();
628 Timer timer(true, "Enter and Exit isolate"); 628 Timer timer(true, "Enter and Exit isolate");
629 timer.Start(); 629 timer.Start();
630 for (intptr_t i = 0; i < kLoopCount; i++) { 630 for (intptr_t i = 0; i < kLoopCount; i++) {
631 Dart_ExitIsolate(); 631 Dart_ExitIsolate();
632 Dart_EnterIsolate(isolate); 632 Dart_EnterIsolate(isolate);
633 } 633 }
634 timer.Stop(); 634 timer.Stop();
635 int64_t elapsed_time = timer.TotalElapsedTime(); 635 int64_t elapsed_time = timer.TotalElapsedTime();
636 benchmark->set_score(elapsed_time); 636 benchmark->set_score(elapsed_time);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 thread); 748 thread);
749 reader.ReadObject(); 749 reader.ReadObject();
750 free(buffer); 750 free(buffer);
751 } 751 }
752 timer.Stop(); 752 timer.Stop();
753 int64_t elapsed_time = timer.TotalElapsedTime(); 753 int64_t elapsed_time = timer.TotalElapsedTime();
754 benchmark->set_score(elapsed_time); 754 benchmark->set_score(elapsed_time);
755 } 755 }
756 756
757 } // namespace dart 757 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/bootstrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698