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

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

Issue 10897014: Performance improvement for the Dart VM runtime method (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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.cc » ('j') | runtime/vm/dart_api_impl.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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 Dart_NewString("benchmark"), 193 Dart_NewString("benchmark"),
194 1, 194 1,
195 args); 195 args);
196 timer.Stop(); 196 timer.Stop();
197 int64_t elapsed_time = timer.TotalElapsedTime(); 197 int64_t elapsed_time = timer.TotalElapsedTime();
198 benchmark->set_score(elapsed_time); 198 benchmark->set_score(elapsed_time);
199 } 199 }
200 200
201 201
202 // 202 //
203 // Measure time accessing internal and external strings.
204 //
205 BENCHMARK(DartStringAccess) {
206 const int kNumIterations = 10000000;
207 Timer timer(true, "DartStringAccess benchmark");
208 timer.Start();
209 Dart_EnterScope();
210
211 // Create strings.
212 uint8_t data8[] = { 'o', 'n', 'e', 0xFF };
213 int external_peer_data = 123;
214 Dart_Handle external_string = Dart_NewExternalString8(data8,
215 ARRAY_SIZE(data8),
216 &external_peer_data,
217 NULL);
218 Dart_Handle internal_string = Dart_NewString("two");
219
220 // Run benchmark.
221 for (int64_t i = 0; i < kNumIterations; i++) {
222 EXPECT(Dart_IsString(internal_string));
223 EXPECT(Dart_IsString8(internal_string));
224 EXPECT(Dart_IsString16(internal_string));
225 EXPECT(!Dart_IsExternalString(internal_string));
226 EXPECT_VALID(external_string);
227 EXPECT(Dart_IsExternalString(external_string));
228 void* external_peer = NULL;
229 // 80% of benchmark is spent in the following call.
Ivan Posva 2012/08/29 05:59:30 Is the 80% value still correct here?
230 EXPECT_VALID(Dart_ExternalStringGetPeer(external_string, &external_peer));
231 EXPECT_EQ(&external_peer_data, external_peer);
232 }
233
234 Dart_ExitScope();
235 timer.Stop();
236 int64_t elapsed_time = timer.TotalElapsedTime();
237 benchmark->set_score(elapsed_time);
238 }
239
240
241 //
203 // Measure compile of all dart2js(compiler) functions. 242 // Measure compile of all dart2js(compiler) functions.
204 // 243 //
205 static char* ComputeDart2JSPath(const char* arg) { 244 static char* ComputeDart2JSPath(const char* arg) {
206 char buffer[2048]; 245 char buffer[2048];
207 char* dart2js_path = strdup(File::GetCanonicalPath(arg)); 246 char* dart2js_path = strdup(File::GetCanonicalPath(arg));
208 const char* compiler_path = "%s%slib%scompiler%scompiler.dart"; 247 const char* compiler_path = "%s%slib%scompiler%scompiler.dart";
209 const char* path_separator = File::PathSeparator(); 248 const char* path_separator = File::PathSeparator();
210 ASSERT(path_separator != NULL && strlen(path_separator) == 1); 249 ASSERT(path_separator != NULL && strlen(path_separator) == 1);
211 char* ptr = strrchr(dart2js_path, *path_separator); 250 char* ptr = strrchr(dart2js_path, *path_separator);
212 while (ptr != NULL) { 251 while (ptr != NULL) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest")); 388 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest"));
350 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); 389 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL);
351 EXPECT_VALID(result); 390 EXPECT_VALID(result);
352 int64_t elapsed_time = 0; 391 int64_t elapsed_time = 0;
353 result = Dart_IntegerToInt64(result, &elapsed_time); 392 result = Dart_IntegerToInt64(result, &elapsed_time);
354 EXPECT_VALID(result); 393 EXPECT_VALID(result);
355 benchmark->set_score(elapsed_time); 394 benchmark->set_score(elapsed_time);
356 } 395 }
357 396
358 } // namespace dart 397 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | runtime/vm/dart_api_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698