| 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/file.h" | 7 #include "bin/file.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 | 10 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 EXPECT(!Dart_IsError(result)); | 140 EXPECT(!Dart_IsError(result)); |
| 141 if (strcmp(cstr, "init") == 0) { | 141 if (strcmp(cstr, "init") == 0) { |
| 142 return InitNativeFields; | 142 return InitNativeFields; |
| 143 } else { | 143 } else { |
| 144 return UseDartApi; | 144 return UseDartApi; |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 | 148 |
| 149 BENCHMARK(UseDartApi) { | 149 BENCHMARK(UseDartApi) { |
| 150 const int kNumIterations = 100000; | 150 const int kNumIterations = 1000000; |
| 151 const char* kScriptChars = | 151 const char* kScriptChars = |
| 152 "class Class extends NativeFieldsWrapper{\n" | 152 "class Class extends NativeFieldsWrapper{\n" |
| 153 " int init() native 'init';\n" | 153 " int init() native 'init';\n" |
| 154 " int method(int param1, int param2) native 'method';\n" | 154 " int method(int param1, int param2) native 'method';\n" |
| 155 "}\n" | 155 "}\n" |
| 156 "\n" | 156 "\n" |
| 157 "void benchmark(int count) {\n" | 157 "void benchmark(int count) {\n" |
| 158 " Class c = new Class();\n" | 158 " Class c = new Class();\n" |
| 159 " c.init();\n" | 159 " c.init();\n" |
| 160 " for (int i = 0; i < count; i++) {\n" | 160 " for (int i = 0; i < count; i++) {\n" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver)); | 336 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver)); |
| 337 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest")); | 337 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest")); |
| 338 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); | 338 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); |
| 339 EXPECT_VALID(result); | 339 EXPECT_VALID(result); |
| 340 int64_t elapsed_time = 0; | 340 int64_t elapsed_time = 0; |
| 341 EXPECT(!Dart_IsError(Dart_IntegerToInt64(result, &elapsed_time))); | 341 EXPECT(!Dart_IsError(Dart_IntegerToInt64(result, &elapsed_time))); |
| 342 benchmark->set_score(elapsed_time); | 342 benchmark->set_score(elapsed_time); |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace dart | 345 } // namespace dart |
| OLD | NEW |