jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
function json_deserialize_helper(key,value) {
if ( typeof value === 'string' ) {
var regexp = /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\d\dZ$/.exec(value);
if ( regexp ) {
return new Date(value);
}
}
return value;
}
function json_deserialize_helper2(key, value) {
if (typeof value === 'string') {
var regexp = /^\~(\d*)$/.exec(value);
if (regexp)
return new Date(Number(regexp[1]));
}
return value;
}
function json_serialize_helper(key, value) {
if ( typeof value == 'string') {
var test = /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\d\dZ$/.exec(value);
if ( test )
return '~' + new Date(test[0]).getTime();
}
return value;
}
var stringify = {test:new Date()};
console.log( JSON.parse(JSON.stringify( stringify, json_serialize_helper ), json_deserialize_helper2).test.getDate() )
console.log( JSON.parse(JSON.stringify( stringify ), json_deserialize_helper).test.getDate() )
Ready to run.
Test | Ops/sec | |
---|---|---|
non serialized |
| ready |
serialized |
| ready |
serialized as timestamp |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.