mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
9 years ago
7 changed files with 176 additions and 2 deletions
@ -0,0 +1,39 @@ |
|||
if (typeof print !== 'function') { print = console.log; } |
|||
|
|||
function test() { |
|||
var tmp1 = []; |
|||
var tmp2 = []; |
|||
var tmp3 = []; |
|||
var i, n, buf; |
|||
|
|||
print('build'); |
|||
buf = Duktape.Buffer(1024); |
|||
for (i = 0; i < 1024; i++) { |
|||
buf[i] = Math.random() * 256; |
|||
} |
|||
tmp1 = String(buf); |
|||
for (i = 0; i < 1024; i++) { |
|||
tmp2.push(tmp1); |
|||
} |
|||
tmp2 = tmp2.join(''); |
|||
tmp2 = Duktape.enc('base64', tmp2); |
|||
|
|||
// add newlines, intentionally not a multiple of 4
|
|||
for (i = 0; i < tmp2.length; i += 77) { |
|||
tmp3.push(tmp2.substring(i, i + 77)); |
|||
} |
|||
tmp2 = tmp3.join('\n') + '\n'; |
|||
|
|||
print(tmp2.length); |
|||
print('run'); |
|||
for (i = 0; i < 1000; i++) { |
|||
Duktape.dec('base64', tmp2); |
|||
} |
|||
} |
|||
|
|||
try { |
|||
test(); |
|||
} catch (e) { |
|||
print(e.stack || e); |
|||
throw e; |
|||
} |
@ -0,0 +1,29 @@ |
|||
import math |
|||
import random |
|||
|
|||
def test(): |
|||
tmp1 = [] |
|||
tmp2 = [] |
|||
|
|||
print('build') |
|||
for i in xrange(1024): |
|||
tmp1.append('%x' % math.floor(random.random() * 16)) |
|||
tmp1 = ''.join(tmp1) |
|||
for i in xrange(1024): |
|||
tmp2.append(tmp1) |
|||
tmp2 = ''.join(tmp2) |
|||
tmp2 = tmp2.encode('base64') |
|||
|
|||
tmp3 = [] |
|||
i = 0 |
|||
while i < len(tmp2): |
|||
tmp3.append(tmp2[i:i+77]) |
|||
i += 77 |
|||
tmp2 = '\n'.join(tmp3) + '\n' |
|||
|
|||
print(len(tmp2)) |
|||
print('run') |
|||
for i in xrange(1000): |
|||
ign = tmp2.decode('base64') |
|||
|
|||
test() |
@ -0,0 +1,32 @@ |
|||
if (typeof print !== 'function') { print = console.log; } |
|||
|
|||
function test() { |
|||
var tmp1 = []; |
|||
var tmp2 = []; |
|||
var i, n, buf; |
|||
|
|||
print('build'); |
|||
buf = Duktape.Buffer(1024); |
|||
for (i = 0; i < 1024; i++) { |
|||
buf[i] = Math.random() * 256; |
|||
} |
|||
tmp1 = String(buf); |
|||
for (i = 0; i < 1024; i++) { |
|||
tmp2.push(tmp1); |
|||
} |
|||
tmp2 = tmp2.join(''); |
|||
tmp2 = Duktape.enc('base64', tmp2); |
|||
|
|||
print(tmp2.length); |
|||
print('run'); |
|||
for (i = 0; i < 1000; i++) { |
|||
Duktape.dec('base64', tmp2); |
|||
} |
|||
} |
|||
|
|||
try { |
|||
test(); |
|||
} catch (e) { |
|||
print(e.stack || e); |
|||
throw e; |
|||
} |
@ -0,0 +1,22 @@ |
|||
import math |
|||
import random |
|||
|
|||
def test(): |
|||
tmp1 = [] |
|||
tmp2 = [] |
|||
|
|||
print('build') |
|||
for i in xrange(1024): |
|||
tmp1.append('%x' % math.floor(random.random() * 16)) |
|||
tmp1 = ''.join(tmp1) |
|||
for i in xrange(1024): |
|||
tmp2.append(tmp1) |
|||
tmp2 = ''.join(tmp2) |
|||
tmp2 = tmp2.encode('base64') |
|||
|
|||
print(len(tmp2)) |
|||
print('run') |
|||
for i in xrange(1000): |
|||
ign = tmp2.decode('base64') |
|||
|
|||
test() |
@ -0,0 +1,31 @@ |
|||
if (typeof print !== 'function') { print = console.log; } |
|||
|
|||
function test() { |
|||
var tmp1 = []; |
|||
var tmp2 = []; |
|||
var i, n, buf; |
|||
|
|||
print('build'); |
|||
buf = Duktape.Buffer(1024); |
|||
for (i = 0; i < 1024; i++) { |
|||
buf[i] = Math.random() * 256; |
|||
} |
|||
tmp1 = String(buf); |
|||
for (i = 0; i < 1024; i++) { |
|||
tmp2.push(tmp1); |
|||
} |
|||
tmp2 = Duktape.Buffer(tmp2.join('')); |
|||
|
|||
print(tmp2.length); |
|||
print('run'); |
|||
for (i = 0; i < 1000; i++) { |
|||
Duktape.enc('base64', tmp2); |
|||
} |
|||
} |
|||
|
|||
try { |
|||
test(); |
|||
} catch (e) { |
|||
print(e.stack || e); |
|||
throw e; |
|||
} |
@ -0,0 +1,21 @@ |
|||
import math |
|||
import random |
|||
|
|||
def test(): |
|||
tmp1 = [] |
|||
tmp2 = [] |
|||
|
|||
print('build') |
|||
for i in xrange(1024): |
|||
tmp1.append(chr(int(math.floor(random.random() * 256)))) |
|||
tmp1 = ''.join(tmp1) |
|||
for i in xrange(1024): |
|||
tmp2.append(tmp1) |
|||
tmp2 = ''.join(tmp2) |
|||
|
|||
print(len(tmp2)) |
|||
print('run') |
|||
for i in xrange(1000): |
|||
ign = tmp2.encode('base64') |
|||
|
|||
test() |
Loading…
Reference in new issue