Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: runtime/vm/benchmark_test.cc

Issue 22980022: Setup a peer for read only strings that are not externalized in (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // 191 //
192 BENCHMARK(DartStringAccess) { 192 BENCHMARK(DartStringAccess) {
193 const int kNumIterations = 10000000; 193 const int kNumIterations = 10000000;
194 Timer timer(true, "DartStringAccess benchmark"); 194 Timer timer(true, "DartStringAccess benchmark");
195 timer.Start(); 195 timer.Start();
196 Dart_EnterScope(); 196 Dart_EnterScope();
197 197
198 // Create strings. 198 // Create strings.
199 uint8_t data8[] = { 'o', 'n', 'e', 0xFF }; 199 uint8_t data8[] = { 'o', 'n', 'e', 0xFF };
200 int external_peer_data = 123; 200 int external_peer_data = 123;
201 intptr_t char_size;
202 intptr_t str_len;
201 Dart_Handle external_string = Dart_NewExternalLatin1String( 203 Dart_Handle external_string = Dart_NewExternalLatin1String(
202 data8, ARRAY_SIZE(data8), &external_peer_data, NULL); 204 data8, ARRAY_SIZE(data8), &external_peer_data, NULL);
203 Dart_Handle internal_string = NewString("two"); 205 Dart_Handle internal_string = NewString("two");
204 206
205 // Run benchmark. 207 // Run benchmark.
206 for (int64_t i = 0; i < kNumIterations; i++) { 208 for (int64_t i = 0; i < kNumIterations; i++) {
207 EXPECT(Dart_IsString(internal_string)); 209 EXPECT(Dart_IsString(internal_string));
208 EXPECT(!Dart_IsExternalString(internal_string)); 210 EXPECT(!Dart_IsExternalString(internal_string));
209 EXPECT_VALID(external_string); 211 EXPECT_VALID(external_string);
210 EXPECT(Dart_IsExternalString(external_string)); 212 EXPECT(Dart_IsExternalString(external_string));
211 void* external_peer = NULL; 213 void* external_peer = NULL;
212 EXPECT_VALID(Dart_ExternalStringGetPeer(external_string, &external_peer)); 214 EXPECT_VALID(Dart_StringGetProperties(external_string,
215 &char_size,
216 &str_len,
217 &external_peer));
218 EXPECT_EQ(1, char_size);
219 EXPECT_EQ(4, str_len);
213 EXPECT_EQ(&external_peer_data, external_peer); 220 EXPECT_EQ(&external_peer_data, external_peer);
214 } 221 }
215 222
216 Dart_ExitScope(); 223 Dart_ExitScope();
217 timer.Stop(); 224 timer.Stop();
218 int64_t elapsed_time = timer.TotalElapsedTime(); 225 int64_t elapsed_time = timer.TotalElapsedTime();
219 benchmark->set_score(elapsed_time); 226 benchmark->set_score(elapsed_time);
220 } 227 }
221 228
222 229
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 467
461 Timer timer(true, "currentMirrorSystem() benchmark"); 468 Timer timer(true, "currentMirrorSystem() benchmark");
462 timer.Start(); 469 timer.Start();
463 Dart_Invoke(lib, NewString("benchmark"), 0, NULL); 470 Dart_Invoke(lib, NewString("benchmark"), 0, NULL);
464 timer.Stop(); 471 timer.Stop();
465 int64_t elapsed_time = timer.TotalElapsedTime(); 472 int64_t elapsed_time = timer.TotalElapsedTime();
466 benchmark->set_score(elapsed_time); 473 benchmark->set_score(elapsed_time);
467 } 474 }
468 475
469 } // namespace dart 476 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698