| 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/builtin.h" |
| 8 #include "bin/file.h" | 8 #include "bin/file.h" |
| 9 #include "bin/isolate_data.h" | 9 #include "bin/isolate_data.h" |
| 10 | 10 |
| 11 #include "platform/assert.h" | 11 #include "platform/assert.h" |
| 12 #include "platform/globals.h" | 12 #include "platform/globals.h" |
| 13 | 13 |
| 14 #include "vm/compiler_stats.h" | 14 #include "vm/compiler_stats.h" |
| 15 #include "vm/dart_api_impl.h" | 15 #include "vm/dart_api_impl.h" |
| 16 #include "vm/stack_frame.h" | 16 #include "vm/stack_frame.h" |
| 17 #include "vm/unit_test.h" | 17 #include "vm/unit_test.h" |
| 18 | 18 |
| 19 using dart::bin::File; | 19 using dart::bin::File; |
| 20 | 20 |
| 21 namespace dart { | 21 namespace dart { |
| 22 | 22 |
| 23 DECLARE_FLAG(bool, background_compilation); | |
| 24 | |
| 25 Benchmark* Benchmark::first_ = NULL; | 23 Benchmark* Benchmark::first_ = NULL; |
| 26 Benchmark* Benchmark::tail_ = NULL; | 24 Benchmark* Benchmark::tail_ = NULL; |
| 27 const char* Benchmark::executable_ = NULL; | 25 const char* Benchmark::executable_ = NULL; |
| 28 | 26 |
| 29 | 27 |
| 30 // | 28 // |
| 31 // Measure compile of all dart2js(compiler) functions. | 29 // Measure compile of all dart2js(compiler) functions. |
| 32 // | 30 // |
| 33 static char* ComputeDart2JSPath(const char* arg) { | 31 static char* ComputeDart2JSPath(const char* arg) { |
| 34 char buffer[2048]; | 32 char buffer[2048]; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 Dart_Handle lib = TestCase::LoadTestScript( | 172 Dart_Handle lib = TestCase::LoadTestScript( |
| 175 "import 'pkg/compiler/lib/compiler.dart';", | 173 "import 'pkg/compiler/lib/compiler.dart';", |
| 176 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); | 174 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); |
| 177 EXPECT_VALID(lib); | 175 EXPECT_VALID(lib); |
| 178 } | 176 } |
| 179 CompilerStats* stats = thread->isolate()->compiler_stats(); | 177 CompilerStats* stats = thread->isolate()->compiler_stats(); |
| 180 ASSERT(stats != NULL); | 178 ASSERT(stats != NULL); |
| 181 stats->EnableBenchmark(); | 179 stats->EnableBenchmark(); |
| 182 Timer timer(true, "Compile all of dart2js benchmark"); | 180 Timer timer(true, "Compile all of dart2js benchmark"); |
| 183 timer.Start(); | 181 timer.Start(); |
| 182 #if !defined(PRODUCT) |
| 183 // Constant in product mode. |
| 184 const bool old_flag = FLAG_background_compilation; | 184 const bool old_flag = FLAG_background_compilation; |
| 185 FLAG_background_compilation = false; | 185 FLAG_background_compilation = false; |
| 186 #endif |
| 186 Dart_Handle result = Dart_CompileAll(); | 187 Dart_Handle result = Dart_CompileAll(); |
| 188 #if !defined(PRODUCT) |
| 187 FLAG_background_compilation = old_flag; | 189 FLAG_background_compilation = old_flag; |
| 190 #endif |
| 188 EXPECT_VALID(result); | 191 EXPECT_VALID(result); |
| 189 timer.Stop(); | 192 timer.Stop(); |
| 190 int64_t elapsed_time = timer.TotalElapsedTime(); | 193 int64_t elapsed_time = timer.TotalElapsedTime(); |
| 191 benchmark->set_score(elapsed_time); | 194 benchmark->set_score(elapsed_time); |
| 192 free(dart_root); | 195 free(dart_root); |
| 193 free(script); | 196 free(script); |
| 194 } | 197 } |
| 195 | 198 |
| 196 | 199 |
| 197 #endif // !PRODUCT | 200 #endif // !PRODUCT |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); | 383 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); |
| 381 EXPECT_VALID(lib); | 384 EXPECT_VALID(lib); |
| 382 } else { | 385 } else { |
| 383 Dart_Handle lib = TestCase::LoadTestScript( | 386 Dart_Handle lib = TestCase::LoadTestScript( |
| 384 "import 'pkg/compiler/lib/compiler.dart';", | 387 "import 'pkg/compiler/lib/compiler.dart';", |
| 385 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); | 388 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); |
| 386 EXPECT_VALID(lib); | 389 EXPECT_VALID(lib); |
| 387 } | 390 } |
| 388 Timer timer(true, "Compile all of dart2js benchmark"); | 391 Timer timer(true, "Compile all of dart2js benchmark"); |
| 389 timer.Start(); | 392 timer.Start(); |
| 393 #if !defined(PRODUCT) |
| 390 const bool old_flag = FLAG_background_compilation; | 394 const bool old_flag = FLAG_background_compilation; |
| 391 FLAG_background_compilation = false; | 395 FLAG_background_compilation = false; |
| 396 #endif |
| 392 Dart_Handle result = Dart_CompileAll(); | 397 Dart_Handle result = Dart_CompileAll(); |
| 398 #if !defined(PRODUCT) |
| 393 FLAG_background_compilation = old_flag; | 399 FLAG_background_compilation = old_flag; |
| 400 #endif |
| 394 EXPECT_VALID(result); | 401 EXPECT_VALID(result); |
| 395 timer.Stop(); | 402 timer.Stop(); |
| 396 int64_t elapsed_time = timer.TotalElapsedTime(); | 403 int64_t elapsed_time = timer.TotalElapsedTime(); |
| 397 benchmark->set_score(elapsed_time); | 404 benchmark->set_score(elapsed_time); |
| 398 free(dart_root); | 405 free(dart_root); |
| 399 free(script); | 406 free(script); |
| 400 } | 407 } |
| 401 | 408 |
| 402 | 409 |
| 403 // | 410 // |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 thread); | 725 thread); |
| 719 reader.ReadObject(); | 726 reader.ReadObject(); |
| 720 free(buffer); | 727 free(buffer); |
| 721 } | 728 } |
| 722 timer.Stop(); | 729 timer.Stop(); |
| 723 int64_t elapsed_time = timer.TotalElapsedTime(); | 730 int64_t elapsed_time = timer.TotalElapsedTime(); |
| 724 benchmark->set_score(elapsed_time); | 731 benchmark->set_score(elapsed_time); |
| 725 } | 732 } |
| 726 | 733 |
| 727 } // namespace dart | 734 } // namespace dart |
| OLD | NEW |