| 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/builtin.h" | 
|    7 #include "bin/file.h" |    8 #include "bin/file.h" | 
|    8  |    9  | 
|    9 #include "platform/assert.h" |   10 #include "platform/assert.h" | 
|   10  |   11  | 
|   11 #include "vm/dart_api_impl.h" |   12 #include "vm/dart_api_impl.h" | 
|   12 #include "vm/stack_frame.h" |   13 #include "vm/stack_frame.h" | 
|   13 #include "vm/unit_test.h" |   14 #include "vm/unit_test.h" | 
|   14  |   15  | 
|   15 using dart::bin::File; |   16 using dart::bin::File; | 
|   16  |   17  | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|   27     benchmark->RunBenchmark(); |   28     benchmark->RunBenchmark(); | 
|   28     benchmark = benchmark->next_; |   29     benchmark = benchmark->next_; | 
|   29   } |   30   } | 
|   30 } |   31 } | 
|   31  |   32  | 
|   32  |   33  | 
|   33 // |   34 // | 
|   34 // Measure compile of all functions in dart core lib classes. |   35 // Measure compile of all functions in dart core lib classes. | 
|   35 // |   36 // | 
|   36 BENCHMARK(CorelibCompileAll) { |   37 BENCHMARK(CorelibCompileAll) { | 
 |   38   bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); | 
 |   39   bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); | 
|   37   Timer timer(true, "Compile all of Core lib benchmark"); |   40   Timer timer(true, "Compile all of Core lib benchmark"); | 
|   38   timer.Start(); |   41   timer.Start(); | 
|   39   const Error& error = Error::Handle(benchmark->isolate(), |   42   const Error& error = Error::Handle(benchmark->isolate(), | 
|   40                                      Library::CompileAll()); |   43                                      Library::CompileAll()); | 
|   41   if (!error.IsNull()) { |   44   if (!error.IsNull()) { | 
|   42     OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", |   45     OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", | 
|   43                  error.ToErrorCString()); |   46                  error.ToErrorCString()); | 
|   44   } |   47   } | 
|   45   EXPECT(error.IsNull()); |   48   EXPECT(error.IsNull()); | 
|   46   timer.Stop(); |   49   timer.Stop(); | 
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  258 } |  261 } | 
|  259  |  262  | 
|  260  |  263  | 
|  261 static Dart_NativeFunction NativeResolver(Dart_Handle name, |  264 static Dart_NativeFunction NativeResolver(Dart_Handle name, | 
|  262                                           int arg_count) { |  265                                           int arg_count) { | 
|  263   return &func; |  266   return &func; | 
|  264 } |  267 } | 
|  265  |  268  | 
|  266  |  269  | 
|  267 BENCHMARK(Dart2JSCompileAll) { |  270 BENCHMARK(Dart2JSCompileAll) { | 
 |  271   bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); | 
 |  272   bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); | 
|  268   char* dart_root = ComputeDart2JSPath(Benchmark::Executable()); |  273   char* dart_root = ComputeDart2JSPath(Benchmark::Executable()); | 
|  269   char* script = NULL; |  274   char* script = NULL; | 
|  270   if (dart_root != NULL) { |  275   if (dart_root != NULL) { | 
|  271     Isolate* isolate = Isolate::Current(); |  276     Isolate* isolate = Isolate::Current(); | 
|  272     HANDLESCOPE(isolate); |  277     HANDLESCOPE(isolate); | 
|  273     const char* kFormatStr = |  278     const char* kFormatStr = | 
|  274         "import '%s/sdk/lib/_internal/compiler/compiler.dart';"; |  279         "import '%s/sdk/lib/_internal/compiler/compiler.dart';"; | 
|  275     intptr_t len = OS::SNPrint(NULL, 0, kFormatStr, dart_root) + 1; |  280     intptr_t len = OS::SNPrint(NULL, 0, kFormatStr, dart_root) + 1; | 
|  276     script = reinterpret_cast<char*>(malloc(len)); |  281     script = reinterpret_cast<char*>(malloc(len)); | 
|  277     EXPECT(script != NULL); |  282     EXPECT(script != NULL); | 
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  444  |  449  | 
|  445   // Write snapshot with object content. |  450   // Write snapshot with object content. | 
|  446   FullSnapshotWriter writer(&buffer, &malloc_allocator); |  451   FullSnapshotWriter writer(&buffer, &malloc_allocator); | 
|  447   writer.WriteFullSnapshot(); |  452   writer.WriteFullSnapshot(); | 
|  448   const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); |  453   const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 
|  449   ASSERT(snapshot->kind() == Snapshot::kFull); |  454   ASSERT(snapshot->kind() == Snapshot::kFull); | 
|  450   benchmark->set_score(snapshot->length()); |  455   benchmark->set_score(snapshot->length()); | 
|  451 } |  456 } | 
|  452  |  457  | 
|  453 }  // namespace dart |  458 }  // namespace dart | 
| OLD | NEW |