OLD | NEW |
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 kScriptChars, | 166 kScriptChars, |
167 reinterpret_cast<Dart_NativeEntryResolver>(bm_uda_lookup)); | 167 reinterpret_cast<Dart_NativeEntryResolver>(bm_uda_lookup)); |
168 | 168 |
169 // Create a native wrapper class with native fields. | 169 // Create a native wrapper class with native fields. |
170 Dart_Handle result = Dart_CreateNativeWrapperClass( | 170 Dart_Handle result = Dart_CreateNativeWrapperClass( |
171 lib, | 171 lib, |
172 Dart_NewString("NativeFieldsWrapper"), | 172 Dart_NewString("NativeFieldsWrapper"), |
173 1); | 173 1); |
174 EXPECT(!Dart_IsError(result)); | 174 EXPECT(!Dart_IsError(result)); |
175 | 175 |
| 176 Dart_Handle args[1]; |
| 177 args[0] = Dart_NewInteger(kNumIterations); |
| 178 |
| 179 // Warmup first to avoid compilation jitters. |
| 180 Dart_Invoke(lib, |
| 181 Dart_NewString("benchmark"), |
| 182 1, |
| 183 args); |
| 184 |
176 Timer timer(true, "UseDartApi benchmark"); | 185 Timer timer(true, "UseDartApi benchmark"); |
177 timer.Start(); | 186 timer.Start(); |
178 Dart_Handle args[1]; | |
179 args[0] = Dart_NewInteger(kNumIterations); | |
180 Dart_Invoke(lib, | 187 Dart_Invoke(lib, |
181 Dart_NewString("benchmark"), | 188 Dart_NewString("benchmark"), |
182 1, | 189 1, |
183 args); | 190 args); |
184 timer.Stop(); | 191 timer.Stop(); |
185 int64_t elapsed_time = timer.TotalElapsedTime(); | 192 int64_t elapsed_time = timer.TotalElapsedTime(); |
186 benchmark->set_score(elapsed_time); | 193 benchmark->set_score(elapsed_time); |
187 } | 194 } |
188 | 195 |
189 | 196 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver)); | 343 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver)); |
337 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest")); | 344 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest")); |
338 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); | 345 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); |
339 EXPECT_VALID(result); | 346 EXPECT_VALID(result); |
340 int64_t elapsed_time = 0; | 347 int64_t elapsed_time = 0; |
341 EXPECT(!Dart_IsError(Dart_IntegerToInt64(result, &elapsed_time))); | 348 EXPECT(!Dart_IsError(Dart_IntegerToInt64(result, &elapsed_time))); |
342 benchmark->set_score(elapsed_time); | 349 benchmark->set_score(elapsed_time); |
343 } | 350 } |
344 | 351 |
345 } // namespace dart | 352 } // namespace dart |
OLD | NEW |