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

Side by Side Diff: chrome/test/data/sunspider/string-base64.html

Issue 14863013: Update SunSpider benchmark from 0.9.1 to 1.0. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing files Created 7 years, 7 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 | « chrome/test/data/sunspider/json2.js ('k') | chrome/test/data/sunspider/string-fasta.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <head>
3 <!--
4 Copyright (C) 2007 Apple Inc. All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 2. Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14
15 THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 -->
27
28 <title>SunSpider string-base64</title>
29 <link rel="stylesheet" href="sunspider.css">
30 </head>
31
32 <body>
33 <h3>string-base64</h3>
34 <div id="console">
35 </div>
36 <script src="sunspider-record-result.js"></script>
37 <script>
38
39 var _sunSpiderStartDate = new Date();
40
41 /* ***** BEGIN LICENSE BLOCK *****
42 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
43 *
44 * The contents of this file are subject to the Mozilla Public License Version
45 * 1.1 (the "License"); you may not use this file except in compliance with
46 * the License. You may obtain a copy of the License at
47 * http://www.mozilla.org/MPL/
48 *
49 * Software distributed under the License is distributed on an "AS IS" basis,
50 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
51 * for the specific language governing rights and limitations under the
52 * License.
53 *
54 * The Original Code is Mozilla XML-RPC Client component.
55 *
56 * The Initial Developer of the Original Code is
57 * Digital Creations 2, Inc.
58 * Portions created by the Initial Developer are Copyright (C) 2000
59 * the Initial Developer. All Rights Reserved.
60 *
61 * Contributor(s):
62 * Martijn Pieters <mj@digicool.com> (original author)
63 * Samuel Sieb <samuel@sieb.net>
64 *
65 * Alternatively, the contents of this file may be used under the terms of
66 * either the GNU General Public License Version 2 or later (the "GPL"), or
67 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
68 * in which case the provisions of the GPL or the LGPL are applicable instead
69 * of those above. If you wish to allow use of your version of this file only
70 * under the terms of either the GPL or the LGPL, and not to allow others to
71 * use your version of this file under the terms of the MPL, indicate your
72 * decision by deleting the provisions above and replace them with the notice
73 * and other provisions required by the GPL or the LGPL. If you do not delete
74 * the provisions above, a recipient may use your version of this file under
75 * the terms of any one of the MPL, the GPL or the LGPL.
76 *
77 * ***** END LICENSE BLOCK ***** */
78
79 // From: http://lxr.mozilla.org/mozilla/source/extensions/xml-rpc/src/nsXmlRpcCl ient.js#956
80
81 /* Convert data (an array of integers) to a Base64 string. */
82 var toBase64Table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456 789+/';
83 var base64Pad = '=';
84
85 function toBase64(data) {
86 var result = '';
87 var length = data.length;
88 var i;
89 // Convert every three bytes to 4 ascii characters.
90 for (i = 0; i < (length - 2); i += 3) {
91 result += toBase64Table[data[i] >> 2];
92 result += toBase64Table[((data[i] & 0x03) << 4) + (data[i+1] >> 4)];
93 result += toBase64Table[((data[i+1] & 0x0f) << 2) + (data[i+2] >> 6)];
94 result += toBase64Table[data[i+2] & 0x3f];
95 }
96
97 // Convert the remaining 1 or 2 bytes, pad out to 4 characters.
98 if (length%3) {
99 i = length - (length%3);
100 result += toBase64Table[data[i] >> 2];
101 if ((length%3) == 2) {
102 result += toBase64Table[((data[i] & 0x03) << 4) + (data[i+1] >> 4)];
103 result += toBase64Table[(data[i+1] & 0x0f) << 2];
104 result += base64Pad;
105 } else {
106 result += toBase64Table[(data[i] & 0x03) << 4];
107 result += base64Pad + base64Pad;
108 }
109 }
110
111 return result;
112 }
113
114 /* Convert Base64 data to a string */
115 var toBinaryTable = [
116 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
117 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
118 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
119 52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1, 0,-1,-1,
120 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
121 15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
122 -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
123 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
124 ];
125
126 function base64ToString(data) {
127 var result = '';
128 var leftbits = 0; // number of bits decoded, but yet to be appended
129 var leftdata = 0; // bits decoded, but yet to be appended
130
131 // Convert one by one.
132 for (var i = 0; i < data.length; i++) {
133 var c = toBinaryTable[data.charCodeAt(i) & 0x7f];
134 var padding = (data[i] == base64Pad);
135 // Skip illegal characters and whitespace
136 if (c == -1) continue;
137
138 // Collect data into leftdata, update bitcount
139 leftdata = (leftdata << 6) | c;
140 leftbits += 6;
141
142 // If we have 8 or more bits, append 8 bits to the result
143 if (leftbits >= 8) {
144 leftbits -= 8;
145 // Append if not padding.
146 if (!padding)
147 result += String.fromCharCode((leftdata >> leftbits) & 0xff);
148 leftdata &= (1 << leftbits) - 1;
149 }
150 }
151
152 // If there are any bits left, the base64 string was corrupted
153 if (leftbits)
154 throw Components.Exception('Corrupted base64 string');
155
156 return result;
157 }
158
159 var str = "";
160
161 for ( var i = 0; i < 8192; i++ )
162 str += String.fromCharCode( (25 * Math.random()) + 97 );
163
164 for ( var i = 8192; i <= 16384; i *= 2 ) {
165
166 var base64;
167
168 base64 = toBase64(str);
169 base64ToString(base64);
170
171 // Double the string
172 str += str;
173 }
174
175 toBinaryTable = null;
176
177
178 var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
179
180 record(_sunSpiderInterval);
181 </script>
182
183
184 </body>
185 </html>
OLDNEW
« no previous file with comments | « chrome/test/data/sunspider/json2.js ('k') | chrome/test/data/sunspider/string-fasta.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698