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

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

Issue 10825178: Change EXPECT(!Dart_IsError(...)) to EXPECT_VALID(...) in VM tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | « no previous file | runtime/vm/dart_api_impl_test.cc » ('j') | runtime/vm/debugger_api_impl_test.cc » ('J')
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/file.h" 7 #include "bin/file.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 BENCHMARK(CorelibIsolateStartup) { 55 BENCHMARK(CorelibIsolateStartup) {
56 const int kNumIterations = 100; 56 const int kNumIterations = 100;
57 char* err = NULL; 57 char* err = NULL;
58 Dart_Isolate base_isolate = Dart_CurrentIsolate(); 58 Dart_Isolate base_isolate = Dart_CurrentIsolate();
59 Dart_Isolate test_isolate = Dart_CreateIsolate(NULL, NULL, NULL, NULL, &err); 59 Dart_Isolate test_isolate = Dart_CreateIsolate(NULL, NULL, NULL, NULL, &err);
60 EXPECT(test_isolate != NULL); 60 EXPECT(test_isolate != NULL);
61 Dart_EnterScope(); 61 Dart_EnterScope();
62 uint8_t* buffer = NULL; 62 uint8_t* buffer = NULL;
63 intptr_t size = 0; 63 intptr_t size = 0;
64 Dart_Handle result = Dart_CreateSnapshot(&buffer, &size); 64 Dart_Handle result = Dart_CreateSnapshot(&buffer, &size);
65 EXPECT(!Dart_IsError(result)); 65 EXPECT_VALID(result);
66 Timer timer(true, "Core Isolate startup benchmark"); 66 Timer timer(true, "Core Isolate startup benchmark");
67 timer.Start(); 67 timer.Start();
68 for (int i = 0; i < kNumIterations; i++) { 68 for (int i = 0; i < kNumIterations; i++) {
69 Dart_Isolate new_isolate = 69 Dart_Isolate new_isolate =
70 Dart_CreateIsolate(NULL, NULL, buffer, NULL, &err); 70 Dart_CreateIsolate(NULL, NULL, buffer, NULL, &err);
71 EXPECT(new_isolate != NULL); 71 EXPECT(new_isolate != NULL);
72 Dart_ShutdownIsolate(); 72 Dart_ShutdownIsolate();
73 } 73 }
74 timer.Stop(); 74 timer.Stop();
75 int64_t elapsed_time = timer.TotalElapsedTime(); 75 int64_t elapsed_time = timer.TotalElapsedTime();
76 benchmark->set_score(elapsed_time / kNumIterations); 76 benchmark->set_score(elapsed_time / kNumIterations);
77 Dart_EnterIsolate(test_isolate); 77 Dart_EnterIsolate(test_isolate);
78 Dart_ExitScope(); 78 Dart_ExitScope();
79 Dart_ShutdownIsolate(); 79 Dart_ShutdownIsolate();
80 Dart_EnterIsolate(base_isolate); 80 Dart_EnterIsolate(base_isolate);
81 } 81 }
82 82
83 83
84 // 84 //
85 // Measure invocation of Dart API functions. 85 // Measure invocation of Dart API functions.
86 // 86 //
87 static void InitNativeFields(Dart_NativeArguments args) { 87 static void InitNativeFields(Dart_NativeArguments args) {
88 Dart_EnterScope(); 88 Dart_EnterScope();
89 int count = Dart_GetNativeArgumentCount(args); 89 int count = Dart_GetNativeArgumentCount(args);
90 EXPECT_EQ(1, count); 90 EXPECT_EQ(1, count);
91 91
92 Dart_Handle recv = Dart_GetNativeArgument(args, 0); 92 Dart_Handle recv = Dart_GetNativeArgument(args, 0);
93 EXPECT(!Dart_IsError(recv)); 93 EXPECT_VALID(recv);
94 Dart_Handle result = Dart_SetNativeInstanceField(recv, 0, 7); 94 Dart_Handle result = Dart_SetNativeInstanceField(recv, 0, 7);
95 EXPECT(!Dart_IsError(result)); 95 EXPECT_VALID(result);
96 96
97 Dart_ExitScope(); 97 Dart_ExitScope();
98 } 98 }
99 99
100 100
101 // The specific api functions called here are a bit arbitrary. We are 101 // The specific api functions called here are a bit arbitrary. We are
102 // trying to get a sense of the overhead for using the dart api. 102 // trying to get a sense of the overhead for using the dart api.
103 static void UseDartApi(Dart_NativeArguments args) { 103 static void UseDartApi(Dart_NativeArguments args) {
104 Dart_EnterScope(); 104 Dart_EnterScope();
105 int count = Dart_GetNativeArgumentCount(args); 105 int count = Dart_GetNativeArgumentCount(args);
106 EXPECT_EQ(3, count); 106 EXPECT_EQ(3, count);
107 107
108 // Get the receiver. 108 // Get the receiver.
109 Dart_Handle recv = Dart_GetNativeArgument(args, 0); 109 Dart_Handle recv = Dart_GetNativeArgument(args, 0);
110 EXPECT(!Dart_IsError(recv)); 110 EXPECT_VALID(recv);
111 111
112 // Get param1. 112 // Get param1.
113 Dart_Handle param1 = Dart_GetNativeArgument(args, 1); 113 Dart_Handle param1 = Dart_GetNativeArgument(args, 1);
114 EXPECT(!Dart_IsError(param1)); 114 EXPECT_VALID(param1);
115 EXPECT(Dart_IsInteger(param1)); 115 EXPECT(Dart_IsInteger(param1));
116 bool fits = false; 116 bool fits = false;
117 Dart_Handle result = Dart_IntegerFitsIntoInt64(param1, &fits); 117 Dart_Handle result = Dart_IntegerFitsIntoInt64(param1, &fits);
118 EXPECT(!Dart_IsError(result) && fits); 118 EXPECT_VALID(result);
119 EXPECT(fits);
119 int64_t value1; 120 int64_t value1;
120 result = Dart_IntegerToInt64(param1, &value1); 121 result = Dart_IntegerToInt64(param1, &value1);
121 EXPECT(!Dart_IsError(result)); 122 EXPECT_VALID(result);
122 EXPECT_LE(0, value1); 123 EXPECT_LE(0, value1);
123 EXPECT_LE(value1, 1000000); 124 EXPECT_LE(value1, 1000000);
124 125
125 // Get native field from receiver. 126 // Get native field from receiver.
126 intptr_t value2; 127 intptr_t value2;
127 result = Dart_GetNativeInstanceField(recv, 0, &value2); 128 result = Dart_GetNativeInstanceField(recv, 0, &value2);
128 EXPECT(!Dart_IsError(result)); 129 EXPECT_VALID(result);
129 EXPECT_EQ(7, value2); 130 EXPECT_EQ(7, value2);
130 131
131 // Return param + receiver.field. 132 // Return param + receiver.field.
132 Dart_SetReturnValue(args, Dart_NewInteger(value1 * value2)); 133 Dart_SetReturnValue(args, Dart_NewInteger(value1 * value2));
133 Dart_ExitScope(); 134 Dart_ExitScope();
134 } 135 }
135 136
136 137
137 static Dart_NativeFunction bm_uda_lookup(Dart_Handle name, int argument_count) { 138 static Dart_NativeFunction bm_uda_lookup(Dart_Handle name, int argument_count) {
138 const char* cstr = NULL; 139 const char* cstr = NULL;
139 Dart_Handle result = Dart_StringToCString(name, &cstr); 140 Dart_Handle result = Dart_StringToCString(name, &cstr);
140 EXPECT(!Dart_IsError(result)); 141 EXPECT_VALID(result);
141 if (strcmp(cstr, "init") == 0) { 142 if (strcmp(cstr, "init") == 0) {
142 return InitNativeFields; 143 return InitNativeFields;
143 } else { 144 } else {
144 return UseDartApi; 145 return UseDartApi;
145 } 146 }
146 } 147 }
147 148
148 149
149 BENCHMARK(UseDartApi) { 150 BENCHMARK(UseDartApi) {
150 const int kNumIterations = 1000000; 151 const int kNumIterations = 1000000;
(...skipping 13 matching lines...) Expand all
164 165
165 Dart_Handle lib = TestCase::LoadTestScript( 166 Dart_Handle lib = TestCase::LoadTestScript(
166 kScriptChars, 167 kScriptChars,
167 reinterpret_cast<Dart_NativeEntryResolver>(bm_uda_lookup)); 168 reinterpret_cast<Dart_NativeEntryResolver>(bm_uda_lookup));
168 169
169 // Create a native wrapper class with native fields. 170 // Create a native wrapper class with native fields.
170 Dart_Handle result = Dart_CreateNativeWrapperClass( 171 Dart_Handle result = Dart_CreateNativeWrapperClass(
171 lib, 172 lib,
172 Dart_NewString("NativeFieldsWrapper"), 173 Dart_NewString("NativeFieldsWrapper"),
173 1); 174 1);
174 EXPECT(!Dart_IsError(result)); 175 EXPECT_VALID(result);
175 176
176 Dart_Handle args[1]; 177 Dart_Handle args[1];
177 args[0] = Dart_NewInteger(kNumIterations); 178 args[0] = Dart_NewInteger(kNumIterations);
178 179
179 // Warmup first to avoid compilation jitters. 180 // Warmup first to avoid compilation jitters.
180 Dart_Invoke(lib, 181 Dart_Invoke(lib,
181 Dart_NewString("benchmark"), 182 Dart_NewString("benchmark"),
182 1, 183 1,
183 args); 184 args);
184 185
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 Dart_ListSetAt(import_map, 1, Dart_NewString(dart_root)); 244 Dart_ListSetAt(import_map, 1, Dart_NewString(dart_root));
244 } else { 245 } else {
245 import_map = Dart_NewList(0); 246 import_map = Dart_NewList(0);
246 } 247 }
247 const char* kScriptChars = 248 const char* kScriptChars =
248 "#import('${DART_ROOT}/lib/compiler/compiler.dart');"; 249 "#import('${DART_ROOT}/lib/compiler/compiler.dart');";
249 Dart_Handle lib = TestCase::LoadTestScript( 250 Dart_Handle lib = TestCase::LoadTestScript(
250 kScriptChars, 251 kScriptChars,
251 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver), 252 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver),
252 import_map); 253 import_map);
253 EXPECT(!Dart_IsError(lib)); 254 EXPECT_VALID(lib);
254 Timer timer(true, "Compile all of dart2js benchmark"); 255 Timer timer(true, "Compile all of dart2js benchmark");
255 timer.Start(); 256 timer.Start();
256 Dart_Handle result = Dart_CompileAll(); 257 Dart_Handle result = Dart_CompileAll();
257 EXPECT(!Dart_IsError(result)); 258 EXPECT_VALID(result);
258 timer.Stop(); 259 timer.Stop();
259 int64_t elapsed_time = timer.TotalElapsedTime(); 260 int64_t elapsed_time = timer.TotalElapsedTime();
260 benchmark->set_score(elapsed_time); 261 benchmark->set_score(elapsed_time);
261 free(dart_root); 262 free(dart_root);
262 } 263 }
263 264
264 265
265 // 266 //
266 // Measure frame lookup during stack traversal. 267 // Measure frame lookup during stack traversal.
267 // 268 //
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 " return obj.method1(1);" 339 " return obj.method1(1);"
339 " }" 340 " }"
340 "}"; 341 "}";
341 Dart_Handle lib = TestCase::LoadTestScript( 342 Dart_Handle lib = TestCase::LoadTestScript(
342 kScriptChars, 343 kScriptChars,
343 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver)); 344 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver));
344 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest")); 345 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest"));
345 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); 346 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL);
346 EXPECT_VALID(result); 347 EXPECT_VALID(result);
347 int64_t elapsed_time = 0; 348 int64_t elapsed_time = 0;
348 EXPECT(!Dart_IsError(Dart_IntegerToInt64(result, &elapsed_time))); 349 Dart_Handle int64_result = Dart_IntegerToInt64(result, &elapsed_time);
Ivan Posva 2012/08/03 18:59:47 result = Dart_IntegerToInt64(result, &elapsed_time
Kevin Millikin (Google) 2012/08/06 07:49:47 Done.
350 EXPECT_VALID(int64_result);
349 benchmark->set_score(elapsed_time); 351 benchmark->set_score(elapsed_time);
350 } 352 }
351 353
352 } // namespace dart 354 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl_test.cc » ('j') | runtime/vm/debugger_api_impl_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698