| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // | 196 // |
| 197 BENCHMARK(DartStringAccess) { | 197 BENCHMARK(DartStringAccess) { |
| 198 const int kNumIterations = 10000000; | 198 const int kNumIterations = 10000000; |
| 199 Timer timer(true, "DartStringAccess benchmark"); | 199 Timer timer(true, "DartStringAccess benchmark"); |
| 200 timer.Start(); | 200 timer.Start(); |
| 201 Dart_EnterScope(); | 201 Dart_EnterScope(); |
| 202 | 202 |
| 203 // Create strings. | 203 // Create strings. |
| 204 uint8_t data8[] = { 'o', 'n', 'e', 0xFF }; | 204 uint8_t data8[] = { 'o', 'n', 'e', 0xFF }; |
| 205 int external_peer_data = 123; | 205 int external_peer_data = 123; |
| 206 Dart_Handle external_string = Dart_NewExternalUTF8String(data8, | 206 Dart_Handle external_string = Dart_NewExternalLatin1String( |
| 207 ARRAY_SIZE(data8), | 207 data8, ARRAY_SIZE(data8), &external_peer_data, NULL); |
| 208 &external_peer_data, | |
| 209 NULL); | |
| 210 Dart_Handle internal_string = NewString("two"); | 208 Dart_Handle internal_string = NewString("two"); |
| 211 | 209 |
| 212 // Run benchmark. | 210 // Run benchmark. |
| 213 for (int64_t i = 0; i < kNumIterations; i++) { | 211 for (int64_t i = 0; i < kNumIterations; i++) { |
| 214 EXPECT(Dart_IsString(internal_string)); | 212 EXPECT(Dart_IsString(internal_string)); |
| 215 EXPECT(!Dart_IsExternalString(internal_string)); | 213 EXPECT(!Dart_IsExternalString(internal_string)); |
| 216 EXPECT_VALID(external_string); | 214 EXPECT_VALID(external_string); |
| 217 EXPECT(Dart_IsExternalString(external_string)); | 215 EXPECT(Dart_IsExternalString(external_string)); |
| 218 void* external_peer = NULL; | 216 void* external_peer = NULL; |
| 219 EXPECT_VALID(Dart_ExternalStringGetPeer(external_string, &external_peer)); | 217 EXPECT_VALID(Dart_ExternalStringGetPeer(external_string, &external_peer)); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrameTest")); | 382 Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrameTest")); |
| 385 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 383 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
| 386 EXPECT_VALID(result); | 384 EXPECT_VALID(result); |
| 387 int64_t elapsed_time = 0; | 385 int64_t elapsed_time = 0; |
| 388 result = Dart_IntegerToInt64(result, &elapsed_time); | 386 result = Dart_IntegerToInt64(result, &elapsed_time); |
| 389 EXPECT_VALID(result); | 387 EXPECT_VALID(result); |
| 390 benchmark->set_score(elapsed_time); | 388 benchmark->set_score(elapsed_time); |
| 391 } | 389 } |
| 392 | 390 |
| 393 } // namespace dart | 391 } // namespace dart |
| OLD | NEW |