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

Side by Side Diff: utils/tests/string_encoding/utf8_benchmarks.dart

Issue 9410001: restructure string decoding to support iterable use and include benchmarks for UTF-8 decoding. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: "stop using introduced variable _length. Improve docs. Created 8 years, 10 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
OLDNEW
(Empty)
1 #!/usr/bin/env dart
2 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file.
5
6 #library("BenchmarkTests");
7 #import("../../string_encoding/utf8.dart", prefix: "SE");
8 #import("../../utf8/utf8.dart", prefix: "UT");
9 #source("benchmark_runner.dart");
10
11 void main() {
12
13 final List<int> testEnglishUtf8 = const<int> [
14 0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63,
15 0x6b, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20,
16 0x66, 0x6f, 0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70,
17 0x73, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x74,
18 0x68, 0x65, 0x20, 0x6c, 0x61, 0x7a, 0x79, 0x20,
19 0x64, 0x6f, 0x67, 0x2e];
20
21 final List<int> testDanishUtf8 = const<int>[
22 0x51, 0x75, 0x69, 0x7a, 0x64, 0x65, 0x6c, 0x74,
23 0x61, 0x67, 0x65, 0x72, 0x6e, 0x65, 0x20, 0x73,
24 0x70, 0x69, 0x73, 0x74, 0x65, 0x20, 0x6a, 0x6f,
25 0x72, 0x64, 0x62, 0xc3, 0xa6, 0x72, 0x20, 0x6d,
26 0x65, 0x64, 0x20, 0x66, 0x6c, 0xc3, 0xb8, 0x64,
27 0x65, 0x20, 0x6d, 0x65, 0x6e, 0x73, 0x20, 0x63,
28 0x69, 0x72, 0x6b, 0x75, 0x73, 0x6b, 0x6c, 0x6f,
29 0x76, 0x6e, 0x65, 0x6e, 0x20, 0x57, 0x6f, 0x6c,
30 0x74, 0x68, 0x65, 0x72, 0x20, 0x73, 0x70, 0x69,
31 0x6c, 0x6c, 0x65, 0x64, 0x65, 0x20, 0x70, 0xc3,
32 0xa5, 0x20, 0x78, 0x79, 0x6c, 0x6f, 0x66, 0x6f,
33 0x6e, 0x2e];
34
35 final List<int> testHebrewUtf8 = const<int>[
36 0xd7, 0x93, 0xd7, 0x92, 0x20, 0xd7, 0xa1, 0xd7,
37 0xa7, 0xd7, 0xa8, 0xd7, 0x9f, 0x20, 0xd7, 0xa9,
38 0xd7, 0x98, 0x20, 0xd7, 0x91, 0xd7, 0x99, 0xd7,
39 0x9d, 0x20, 0xd7, 0x9e, 0xd7, 0x90, 0xd7, 0x95,
40 0xd7, 0x9b, 0xd7, 0x96, 0xd7, 0x91, 0x20, 0xd7,
41 0x95, 0xd7, 0x9c, 0xd7, 0xa4, 0xd7, 0xaa, 0xd7,
42 0xa2, 0x20, 0xd7, 0x9e, 0xd7, 0xa6, 0xd7, 0x90,
43 0x20, 0xd7, 0x9c, 0xd7, 0x95, 0x20, 0xd7, 0x97,
44 0xd7, 0x91, 0xd7, 0xa8, 0xd7, 0x94, 0x20, 0xd7,
45 0x90, 0xd7, 0x99, 0xd7, 0x9a, 0x20, 0xd7, 0x94,
46 0xd7, 0xa7, 0xd7, 0x9c, 0xd7, 0x99, 0xd7, 0x98,
47 0xd7, 0x94];
48
49 final List<int> testRussianUtf8 = const<int>[
50 0xd0, 0xa1, 0xd1, 0x8a, 0xd0, 0xb5, 0xd1, 0x88,
51 0xd1, 0x8c, 0x20, 0xd0, 0xb6, 0xd0, 0xb5, 0x20,
52 0xd0, 0xb5, 0xd1, 0x89, 0xd1, 0x91, 0x20, 0xd1,
53 0x8d, 0xd1, 0x82, 0xd0, 0xb8, 0xd1, 0x85, 0x20,
54 0xd0, 0xbc, 0xd1, 0x8f, 0xd0, 0xb3, 0xd0, 0xba,
55 0xd0, 0xb8, 0xd1, 0x85, 0x20, 0xd1, 0x84, 0xd1,
56 0x80, 0xd0, 0xb0, 0xd0, 0xbd, 0xd1, 0x86, 0xd1,
57 0x83, 0xd0, 0xb7, 0xd1, 0x81, 0xd0, 0xba, 0xd0,
58 0xb8, 0xd1, 0x85, 0x20, 0xd0, 0xb1, 0xd1, 0x83,
59 0xd0, 0xbb, 0xd0, 0xbe, 0xd0, 0xba, 0x20, 0xd0,
60 0xb4, 0xd0, 0xb0, 0x20, 0xd0, 0xb2, 0xd1, 0x8b,
61 0xd0, 0xbf, 0xd0, 0xb5, 0xd0, 0xb9, 0x20, 0xd1,
62 0x87, 0xd0, 0xb0, 0xd1, 0x8e];
63
64 final List<int> testGreekUtf8 = const<int>[
65 0xce, 0x93, 0xce, 0xb1, 0xce, 0xb6, 0xce, 0xad,
66 0xce, 0xb5, 0xcf, 0x82, 0x20, 0xce, 0xba, 0xce,
67 0xb1, 0xe1, 0xbd, 0xb6, 0x20, 0xce, 0xbc, 0xcf,
68 0x85, 0xcf, 0x81, 0xcf, 0x84, 0xce, 0xb9, 0xe1,
69 0xbd, 0xb2, 0xcf, 0x82, 0x20, 0xce, 0xb4, 0xe1,
70 0xbd, 0xb2, 0xce, 0xbd, 0x20, 0xce, 0xb8, 0xe1,
71 0xbd, 0xb0, 0x20, 0xce, 0xb2, 0xcf, 0x81, 0xe1,
72 0xbf, 0xb6, 0x20, 0xcf, 0x80, 0xce, 0xb9, 0xe1,
73 0xbd, 0xb0, 0x20, 0xcf, 0x83, 0xcf, 0x84, 0xe1,
74 0xbd, 0xb8, 0x20, 0xcf, 0x87, 0xcf, 0x81, 0xcf,
75 0x85, 0xcf, 0x83, 0xce, 0xb1, 0xcf, 0x86, 0xe1,
76 0xbd, 0xb6, 0x20, 0xce, 0xbe, 0xce, 0xad, 0xcf,
77 0x86, 0xcf, 0x89, 0xcf, 0x84, 0xce, 0xbf];
78
79 final List<int> testKatakanaUtf8 = const<int>[
80 0xe3, 0x82, 0xa4, 0xe3, 0x83, 0xad, 0xe3, 0x83,
81 0x8f, 0xe3, 0x83, 0x8b, 0xe3, 0x83, 0x9b, 0xe3,
82 0x83, 0x98, 0xe3, 0x83, 0x88, 0x20, 0xe3, 0x83,
83 0x81, 0xe3, 0x83, 0xaa, 0xe3, 0x83, 0x8c, 0xe3,
84 0x83, 0xab, 0xe3, 0x83, 0xb2, 0x20, 0xe3, 0x83,
85 0xaf, 0xe3, 0x82, 0xab, 0xe3, 0x83, 0xa8, 0xe3,
86 0x82, 0xbf, 0xe3, 0x83, 0xac, 0xe3, 0x82, 0xbd,
87 0x20, 0xe3, 0x83, 0x84, 0xe3, 0x83, 0x8d, 0xe3,
88 0x83, 0x8a, 0xe3, 0x83, 0xa9, 0xe3, 0x83, 0xa0,
89 0x0a, 0xe3, 0x82, 0xa6, 0xe3, 0x83, 0xb0, 0xe3,
90 0x83, 0x8e, 0xe3, 0x82, 0xaa, 0xe3, 0x82, 0xaf,
91 0xe3, 0x83, 0xa4, 0xe3, 0x83, 0x9e, 0x20, 0xe3,
92 0x82, 0xb1, 0xe3, 0x83, 0x95, 0xe3, 0x82, 0xb3,
93 0xe3, 0x82, 0xa8, 0xe3, 0x83, 0x86, 0x20, 0xe3,
94 0x82, 0xa2, 0xe3, 0x82, 0xb5, 0xe3, 0x82, 0xad,
95 0xe3, 0x83, 0xa6, 0xe3, 0x83, 0xa1, 0xe3, 0x83,
96 0x9f, 0xe3, 0x82, 0xb7, 0x20, 0xe3, 0x83, 0xb1,
97 0xe3, 0x83, 0x92, 0xe3, 0x83, 0xa2, 0xe3, 0x82,
98 0xbb, 0xe3, 0x82, 0xb9, 0xe3, 0x83, 0xb3];
99
100 TimedTestConfig testConfig_1sec =
101 new TimedTestConfig(100, 1 * 1000, blocksize: 1000);
102
103 BenchmarkRunner.runTimed("SE_EN1","string_encoding/decodeUtf8-English1",
104 testConfig_1sec, () =>
105 (new SE.Utf8Decoder(testEnglishUtf8)).decodeRest());
106
107 BenchmarkRunner.runTimed("SE_DA1","string_encoding/decodeUtf8-Danish1",
108 testConfig_1sec, () => (new SE.Utf8Decoder(testDanishUtf8)).decodeRest());
109
110 BenchmarkRunner.runTimed("SE_HE1","string_encoding/decodeUtf8-Hebrew1",
111 testConfig_1sec, () => (new SE.Utf8Decoder(testHebrewUtf8)).decodeRest());
112
113 BenchmarkRunner.runTimed("SE_RU1","string_encoding/decodeUtf8-Russian1",
114 testConfig_1sec, () =>
115 (new SE.Utf8Decoder(testRussianUtf8)).decodeRest());
116
117 BenchmarkRunner.runTimed("SE_EL1","string_encoding/decodeUtf8-Greek",
118 testConfig_1sec, () =>
119 (new SE.Utf8Decoder(testGreekUtf8)).decodeRest());
120
121 BenchmarkRunner.runTimed("SE_JA1","string_encoding/decodeUtf8-Katakana",
122 testConfig_1sec, () =>
123 (new SE.Utf8Decoder(testKatakanaUtf8)).decodeRest());
124
125 BenchmarkRunner.runTimed("UT_EN1","Utf8Decoder/decodeUtf8-English1",
126 testConfig_1sec, () =>
127 (new UT.Utf8Decoder(testEnglishUtf8, 0, testEnglishUtf8.length))
128 .decodeRest());
129
130 BenchmarkRunner.runTimed("UT_DA1","Utf8Decoder/decodeUtf8-Danish1",
131 testConfig_1sec, () =>
132 (new UT.Utf8Decoder(testDanishUtf8, 0, testDanishUtf8.length))
133 .decodeRest());
134
135 BenchmarkRunner.runTimed("UT_HE1","Utf8Decoder/decodeUtf8-Hebrew1",
136 testConfig_1sec, () =>
137 (new UT.Utf8Decoder(testHebrewUtf8, 0, testHebrewUtf8.length))
138 .decodeRest());
139
140 BenchmarkRunner.runTimed("UT_RU1","Utf8Decoder/decodeUtf8-Russian1",
141 testConfig_1sec,
142 () => (new UT.Utf8Decoder(testRussianUtf8, 0, testRussianUtf8.length))
143 .decodeRest());
144
145 BenchmarkRunner.runTimed("UT_EL1","Utf8Decoder/decodeUtf8-Greek",
146 testConfig_1sec, () =>
147 (new UT.Utf8Decoder(testGreekUtf8, 0, testGreekUtf8.length))
148 .decodeRest());
149
150 BenchmarkRunner.runTimed("UT_JA1","Utf8Decoder/decodeUtf8-Katakana",
151 testConfig_1sec,() =>
152 (new UT.Utf8Decoder(testKatakanaUtf8, 0, testKatakanaUtf8.length))
153 .decodeRest());
154 }
155
OLDNEW
« no previous file with comments | « utils/tests/string_encoding/utf32_tests.dart ('k') | utils/tests/string_encoding/utf8_tests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698