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

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

Issue 1541073002: Implement safepointing of threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix-typo Created 4 years, 10 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
« no previous file with comments | « runtime/lib/vmservice.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 21 matching lines...) Expand all
32 } 32 }
33 } 33 }
34 34
35 35
36 // 36 //
37 // Measure compile of all functions in dart core lib classes. 37 // Measure compile of all functions in dart core lib classes.
38 // 38 //
39 BENCHMARK(CorelibCompileAll) { 39 BENCHMARK(CorelibCompileAll) {
40 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); 40 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary);
41 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); 41 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary);
42 TransitionNativeToVM transition(thread);
42 Timer timer(true, "Compile all of Core lib benchmark"); 43 Timer timer(true, "Compile all of Core lib benchmark");
43 timer.Start(); 44 timer.Start();
44 const Error& error = Error::Handle(Library::CompileAll()); 45 const Error& error = Error::Handle(Library::CompileAll());
45 if (!error.IsNull()) { 46 if (!error.IsNull()) {
46 OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", 47 OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s",
47 error.ToErrorCString()); 48 error.ToErrorCString());
48 } 49 }
49 timer.Stop(); 50 timer.Stop();
50 int64_t elapsed_time = timer.TotalElapsedTime(); 51 int64_t elapsed_time = timer.TotalElapsedTime();
51 benchmark->set_score(elapsed_time); 52 benchmark->set_score(elapsed_time);
52 } 53 }
53 54
54 55
55 BENCHMARK(CorelibCompilerStats) { 56 BENCHMARK(CorelibCompilerStats) {
56 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); 57 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary);
57 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); 58 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary);
59 TransitionNativeToVM transition(thread);
58 CompilerStats* stats = thread->isolate()->compiler_stats(); 60 CompilerStats* stats = thread->isolate()->compiler_stats();
59 ASSERT(stats != NULL); 61 ASSERT(stats != NULL);
60 stats->EnableBenchmark(); 62 stats->EnableBenchmark();
61 Timer timer(true, "Compiler stats compiling all of Core lib"); 63 Timer timer(true, "Compiler stats compiling all of Core lib");
62 timer.Start(); 64 timer.Start();
63 const Error& error = Error::Handle(Library::CompileAll()); 65 const Error& error = Error::Handle(Library::CompileAll());
64 if (!error.IsNull()) { 66 if (!error.IsNull()) {
65 OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", 67 OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s",
66 error.ToErrorCString()); 68 error.ToErrorCString());
67 } 69 }
68 timer.Stop(); 70 timer.Stop();
69 int64_t elapsed_time = timer.TotalElapsedTime(); 71 int64_t elapsed_time = timer.TotalElapsedTime();
70 benchmark->set_score(elapsed_time); 72 benchmark->set_score(elapsed_time);
71 } 73 }
72 74
73 75
74 // 76 //
75 // Measure creation of core isolate from a snapshot. 77 // Measure creation of core isolate from a snapshot.
76 // 78 //
77 BENCHMARK(CorelibIsolateStartup) { 79 BENCHMARK(CorelibIsolateStartup) {
78 const int kNumIterations = 1000; 80 const int kNumIterations = 1000;
79 Timer timer(true, "CorelibIsolateStartup"); 81 Timer timer(true, "CorelibIsolateStartup");
80 Isolate* isolate = thread->isolate(); 82 Isolate* isolate = thread->isolate();
81 Thread::ExitIsolate(); 83 Dart_ExitIsolate();
82 for (int i = 0; i < kNumIterations; i++) { 84 for (int i = 0; i < kNumIterations; i++) {
83 timer.Start(); 85 timer.Start();
84 TestCase::CreateTestIsolate(); 86 TestCase::CreateTestIsolate();
85 timer.Stop(); 87 timer.Stop();
86 Dart_ShutdownIsolate(); 88 Dart_ShutdownIsolate();
87 } 89 }
88 benchmark->set_score(timer.TotalElapsedTime() / kNumIterations); 90 benchmark->set_score(timer.TotalElapsedTime() / kNumIterations);
89 Thread::EnterIsolate(isolate); 91 Dart_EnterIsolate(reinterpret_cast<Dart_Isolate>(isolate));
90 } 92 }
91 93
92 94
93 // 95 //
94 // Measure invocation of Dart API functions. 96 // Measure invocation of Dart API functions.
95 // 97 //
96 static void InitNativeFields(Dart_NativeArguments args) { 98 static void InitNativeFields(Dart_NativeArguments args) {
97 Dart_EnterScope(); 99 Dart_EnterScope();
98 int count = Dart_GetNativeArgumentCount(args); 100 int count = Dart_GetNativeArgumentCount(args);
99 EXPECT_EQ(1, count); 101 EXPECT_EQ(1, count);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 137
136 // Return param + receiver.field. 138 // Return param + receiver.field.
137 Dart_SetReturnValue(args, Dart_NewInteger(value1 * receiver_value)); 139 Dart_SetReturnValue(args, Dart_NewInteger(value1 * receiver_value));
138 } 140 }
139 141
140 142
141 static Dart_NativeFunction bm_uda_lookup(Dart_Handle name, 143 static Dart_NativeFunction bm_uda_lookup(Dart_Handle name,
142 int argument_count, 144 int argument_count,
143 bool* auto_setup_scope) { 145 bool* auto_setup_scope) {
144 ASSERT(auto_setup_scope != NULL); 146 ASSERT(auto_setup_scope != NULL);
145 *auto_setup_scope = false; 147 *auto_setup_scope = true;
146 const char* cstr = NULL; 148 const char* cstr = NULL;
147 Dart_Handle result = Dart_StringToCString(name, &cstr); 149 Dart_Handle result = Dart_StringToCString(name, &cstr);
148 EXPECT_VALID(result); 150 EXPECT_VALID(result);
149 if (strcmp(cstr, "init") == 0) { 151 if (strcmp(cstr, "init") == 0) {
150 return InitNativeFields; 152 return InitNativeFields;
151 } else { 153 } else {
152 return UseDartApi; 154 return UseDartApi;
153 } 155 }
154 } 156 }
155 157
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 thread); 688 thread);
687 reader.ReadObject(); 689 reader.ReadObject();
688 } 690 }
689 timer.Stop(); 691 timer.Stop();
690 int64_t elapsed_time = timer.TotalElapsedTime(); 692 int64_t elapsed_time = timer.TotalElapsedTime();
691 benchmark->set_score(elapsed_time); 693 benchmark->set_score(elapsed_time);
692 } 694 }
693 695
694 696
695 BENCHMARK(SimpleMessage) { 697 BENCHMARK(SimpleMessage) {
698 TransitionNativeToVM transition(thread);
696 const Array& array_object = Array::Handle(Array::New(2)); 699 const Array& array_object = Array::Handle(Array::New(2));
697 array_object.SetAt(0, Integer::Handle(Smi::New(42))); 700 array_object.SetAt(0, Integer::Handle(Smi::New(42)));
698 array_object.SetAt(1, Object::Handle()); 701 array_object.SetAt(1, Object::Handle());
699 const intptr_t kLoopCount = 1000000; 702 const intptr_t kLoopCount = 1000000;
700 uint8_t* buffer; 703 uint8_t* buffer;
701 Timer timer(true, "Simple Message"); 704 Timer timer(true, "Simple Message");
702 timer.Start(); 705 timer.Start();
703 for (intptr_t i = 0; i < kLoopCount; i++) { 706 for (intptr_t i = 0; i < kLoopCount; i++) {
704 StackZone zone(thread); 707 StackZone zone(thread);
705 MessageWriter writer(&buffer, &malloc_allocator, true); 708 MessageWriter writer(&buffer, &malloc_allocator, true);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 thread); 751 thread);
749 reader.ReadObject(); 752 reader.ReadObject();
750 free(buffer); 753 free(buffer);
751 } 754 }
752 timer.Stop(); 755 timer.Stop();
753 int64_t elapsed_time = timer.TotalElapsedTime(); 756 int64_t elapsed_time = timer.TotalElapsedTime();
754 benchmark->set_score(elapsed_time); 757 benchmark->set_score(elapsed_time);
755 } 758 }
756 759
757 } // namespace dart 760 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/vmservice.cc ('k') | runtime/vm/bootstrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698