Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fmt_bytenum( n )
- {
- var on = n;
- var i = 0;
- var units = [ "B", "kB", "MB" ];
- while( n > 2048 && i < units.length - 1 )
- {
- n /= 1024;
- i++;
- }
- return n + " " + units[i] + " (" + on + " bytes)";
- }
- function printlns()
- {
- for(var i = 0; i < arguments.length; i++)
- console.log(arguments[i]);
- }
- function ftime(){ return (new Date()).getTime() / 1000; }
- function sys_stat(){ return 0; }
- var count = 100000;
- mem_base = sys_stat(3);
- num_base = sys_stat(6);
- obj = new Map();
- t0 = ftime();
- for( var i = 0; i < count; ++i )
- obj.set( i, ftime() );
- mem_load = sys_stat(3);
- num_load = sys_stat(6);
- t1 = ftime();
- for( var i = 0; i < count; ++i )
- dummy = obj.get( i );
- t2 = ftime();
- for( var i = 0; i < count; ++i )
- obj.delete( i );
- mem_unload = sys_stat(3);
- num_unload = sys_stat(6);
- t3 = ftime();
- obj = null;
- mem_free = sys_stat(3);
- printlns( "-- info --", "count: " + count );
- printlns( "-- time --", "set: " + (t1-t0), "get: " + (t2-t1), "unset: " + (t3-t2) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement