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

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

Issue 12226068: Add snapshot size to the VM benchmarks suite. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/vm/unit_test.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/file.h" 7 #include "bin/file.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 10
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver)); 383 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver));
384 Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrameTest")); 384 Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrameTest"));
385 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); 385 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL);
386 EXPECT_VALID(result); 386 EXPECT_VALID(result);
387 int64_t elapsed_time = 0; 387 int64_t elapsed_time = 0;
388 result = Dart_IntegerToInt64(result, &elapsed_time); 388 result = Dart_IntegerToInt64(result, &elapsed_time);
389 EXPECT_VALID(result); 389 EXPECT_VALID(result);
390 benchmark->set_score(elapsed_time); 390 benchmark->set_score(elapsed_time);
391 } 391 }
392 392
393
394 static uint8_t* malloc_allocator(
395 uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
396 return reinterpret_cast<uint8_t*>(realloc(ptr, new_size));
397 }
398
399
400 BENCHMARK(CoreSnapshotSize) {
401 const char* kScriptChars =
402 "import 'dart:async';\n"
403 "import 'dart:core';\n"
404 "import 'dart:collection';\n"
405 "import 'dart:_collection-dev';\n"
406 "import 'dart:math';\n"
407 "import 'dart:isolate';\n"
408 "import 'dart:mirrors';\n"
409 "import 'dart:scalarlist';\n"
410 "\n";
411
412 // Start an Isolate, load a script and create a full snapshot.
413 uint8_t* buffer;
414 TestCase::LoadTestScript(kScriptChars, NULL);
415 Api::CheckIsolateState(Isolate::Current());
416
417 // Write snapshot with object content.
418 FullSnapshotWriter writer(&buffer, &malloc_allocator);
419 writer.WriteFullSnapshot();
420 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer);
421 ASSERT(snapshot->kind() == Snapshot::kFull);
422 benchmark->set_score(snapshot->length());
423 }
424
425
426 BENCHMARK(StandaloneSnapshotSize) {
427 const char* kScriptChars =
428 "import 'dart:async';\n"
429 "import 'dart:core';\n"
430 "import 'dart:collection';\n"
431 "import 'dart:_collection-dev';\n"
432 "import 'dart:math';\n"
433 "import 'dart:isolate';\n"
434 "import 'dart:mirrors';\n"
435 "import 'dart:scalarlist';\n"
436 "import 'dart:uri';\n"
437 "import 'dart:utf';\n"
438 "import 'dart:json';\n"
439 "import 'dart:crypto';\n"
440 "import 'dart:builtin';\n"
441 "import 'dart:io';\n"
442 "\n";
443
444 // Start an Isolate, load a script and create a full snapshot.
445 uint8_t* buffer;
446 TestCase::LoadTestScript(kScriptChars, NULL);
447 Api::CheckIsolateState(Isolate::Current());
448
449 // Write snapshot with object content.
450 FullSnapshotWriter writer(&buffer, &malloc_allocator);
451 writer.WriteFullSnapshot();
452 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer);
453 ASSERT(snapshot->kind() == Snapshot::kFull);
454 benchmark->set_score(snapshot->length());
455 }
456
393 } // namespace dart 457 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/vm/unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698