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