mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
7 years ago
3 changed files with 72 additions and 11 deletions
@ -0,0 +1,35 @@ |
|||
/* |
|||
* Exercise the internal mechanism for intern checking a string literal |
|||
* pushed using e.g. duk_push_literal(). The ideal test target has a lot |
|||
* of literal interning and minimal other activity. No really good target |
|||
* exists now, but 'String(Buffer.prototype)' just pushes a literal and |
|||
* returns. |
|||
*/ |
|||
|
|||
if (typeof print !== 'function') { print = console.log; } |
|||
|
|||
function test() { |
|||
var S = String; |
|||
var BP = Buffer.prototype; |
|||
var i; |
|||
|
|||
for (i = 0; i < 1e5; i++) { |
|||
S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); |
|||
S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); |
|||
S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); |
|||
S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); |
|||
S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); |
|||
S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); |
|||
S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); |
|||
S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); |
|||
S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); |
|||
S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); S(BP); |
|||
} |
|||
} |
|||
|
|||
try { |
|||
test(); |
|||
} catch (e) { |
|||
print(e.stack || e); |
|||
throw e; |
|||
} |
@ -0,0 +1,26 @@ |
|||
if (typeof print !== 'function') { print = console.log; } |
|||
|
|||
function test() { |
|||
var S = Symbol('foo'); |
|||
var i; |
|||
|
|||
for (i = 0; i < 1e6; i++) { |
|||
String(S); |
|||
String(S); |
|||
String(S); |
|||
String(S); |
|||
String(S); |
|||
String(S); |
|||
String(S); |
|||
String(S); |
|||
String(S); |
|||
String(S); |
|||
} |
|||
} |
|||
|
|||
try { |
|||
test(); |
|||
} catch (e) { |
|||
print(e.stack || e); |
|||
throw e; |
|||
} |
Loading…
Reference in new issue