mirror of
https://github.com/bellard/quickjs.git
synced 2025-05-15 10:45:02 +08:00
fixed hash_map_resize() - added Map/WeakMap in microbench
This commit is contained in:
parent
9f65ef1950
commit
49413985eb
@ -46186,7 +46186,6 @@ static void map_hash_resize(JSContext *ctx, JSMapState *s)
|
|||||||
sizeof(new_hash_table[0]) * new_hash_size, &slack);
|
sizeof(new_hash_table[0]) * new_hash_size, &slack);
|
||||||
if (!new_hash_table)
|
if (!new_hash_table)
|
||||||
return;
|
return;
|
||||||
new_hash_size += slack / sizeof(*new_hash_table);
|
|
||||||
|
|
||||||
for(i = 0; i < new_hash_size; i++)
|
for(i = 0; i < new_hash_size; i++)
|
||||||
init_list_head(&new_hash_table[i]);
|
init_list_head(&new_hash_table[i]);
|
||||||
|
@ -720,22 +720,79 @@ function bigint256_arith(n)
|
|||||||
return bigint_arith(n, 256);
|
return bigint_arith(n, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_collection_add(n)
|
function map_set(n)
|
||||||
{
|
{
|
||||||
var s, i, j, len = 100;
|
var s, i, j, len = 100;
|
||||||
for(j = 0; j < n; j++) {
|
for(j = 0; j < n; j++) {
|
||||||
s = new Set();
|
s = new Map();
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
s.add(String(i), i);
|
s.set(String(i), i);
|
||||||
}
|
}
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
if (!s.has(String(i)))
|
if (!s.has(String(i)))
|
||||||
throw Error("bug in Set");
|
throw Error("bug in Map");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return n * len;
|
return n * len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function map_delete(n)
|
||||||
|
{
|
||||||
|
var a, i, j;
|
||||||
|
|
||||||
|
len = 1000;
|
||||||
|
for(j = 0; j < n; j++) {
|
||||||
|
a = new Map();
|
||||||
|
for(i = 0; i < len; i++) {
|
||||||
|
a.set(String(i), i);
|
||||||
|
}
|
||||||
|
for(i = 0; i < len; i++) {
|
||||||
|
a.delete(String(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len * n;
|
||||||
|
}
|
||||||
|
|
||||||
|
function weak_map_set(n)
|
||||||
|
{
|
||||||
|
var a, i, j, tab;
|
||||||
|
|
||||||
|
len = 1000;
|
||||||
|
tab = [];
|
||||||
|
for(i = 0; i < len; i++) {
|
||||||
|
tab.push({ key: i });
|
||||||
|
}
|
||||||
|
for(j = 0; j < n; j++) {
|
||||||
|
a = new WeakMap();
|
||||||
|
for(i = 0; i < len; i++) {
|
||||||
|
a.set(tab[i], i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len * n;
|
||||||
|
}
|
||||||
|
|
||||||
|
function weak_map_delete(n)
|
||||||
|
{
|
||||||
|
var a, i, j, tab;
|
||||||
|
|
||||||
|
len = 1000;
|
||||||
|
for(j = 0; j < n; j++) {
|
||||||
|
tab = [];
|
||||||
|
for(i = 0; i < len; i++) {
|
||||||
|
tab.push({ key: i });
|
||||||
|
}
|
||||||
|
a = new WeakMap();
|
||||||
|
for(i = 0; i < len; i++) {
|
||||||
|
a.set(tab[i], i);
|
||||||
|
}
|
||||||
|
for(i = 0; i < len; i++) {
|
||||||
|
tab[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len * n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function array_for(n)
|
function array_for(n)
|
||||||
{
|
{
|
||||||
var r, i, j, sum, len = 100;
|
var r, i, j, sum, len = 100;
|
||||||
@ -1189,7 +1246,10 @@ function main(argc, argv, g)
|
|||||||
func_closure_call,
|
func_closure_call,
|
||||||
int_arith,
|
int_arith,
|
||||||
float_arith,
|
float_arith,
|
||||||
set_collection_add,
|
map_set,
|
||||||
|
map_delete,
|
||||||
|
weak_map_set,
|
||||||
|
weak_map_delete,
|
||||||
array_for,
|
array_for,
|
||||||
array_for_in,
|
array_for_in,
|
||||||
array_for_of,
|
array_for_of,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user