Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
test json
(version: 0)
Comparing performance of:
test() vs test2()
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function test() { console.time('parse'); const a = JSON.parse(`{"name":"sysserver","version":"2.0.4","description":"${Math.random() * 10000000}","main":"","scripts":{"start":"node dist/server.js","start-win":"${Math.random() * 10000000}","start:dev":"nodemon","======== BUILD =======":"","build_modules":"cd modules/s30-perco && node-gyp rebuild && cd ../ && cd s30-suprema && node-gyp rebuild && cd ../ && cd s30-video && node-gyp rebuild","package":"node ./scripts/build.js","package:local":"node ./scripts/build.js --build-type=local","clean":"node ./scripts/clean.js","pkg":"pkg -c package.json -t node16-win,node16-linux src/server.js --out-path build","pkg-arm":"pkg -c package.json -t node10.15.3-linux-armv7 dist/server.js --output build/pw-syssrv","======== DOCS =======":"","docs":"node scripts/docs.js","======== TEST =======":"","test":"mocha","lint":"eslint . --ext .ts"},"contributors":[],"dependencies":{"@grpc/grpc-js":"^1.3.6","@grpc/proto-loader":"^0.6.5","@protobufjs/aspromise":"^1.1.2","@types/log4js":"^2.3.5","binary-parser":"1.1.5","heapdump":"^0.3.15","ioredis":"^4.28.5","jpeg-js":"0.3.4","lodash.camelcase":"^4.3.0","log4js":"^6.3.0","long":"2.4.0","protobufjs":"^6.11.2","sax":"${Math.random() * 10000000}","smart-buffer":"1.0.3","underscore":"1.8.3","ws":"^8.3.0","xml2js":"0.4.19","xmlbuilder":"9.0.7"},"devDependencies":{"@PERCoWeb/eslint-config":"^1.1.0","@types/chai":"^4.2.22","@types/mocha":"^9.0.0","@types/node":"16.11.7","@types/sinon":"^10.0.9","chai":"^4.3.4","fs-extra":"^10.1.0","glob":"^7.2.0","mocha":"^9.2.0","nodemon":"^2.0.15","onvif":"file:./modules/onvif","rimraf":"^3.0.2","rtsp-ffmpeg":"0.0.11","s30-biosmart":"file:./modules/s30-biosmart","s30-perco":"file:./modules/s30-perco","s30-suprema":"file:./modules/s30-suprema","s30-video":"file:./modules/s30-video","sinon":"^13.0.0","ts-node":"^10.4.0","typedoc":"^0.22.10","typescript":"^4.5.2"},"pkg":{"scripts":["src/*.js","src/drivers/video/videoStream.js"],"assets":["axxon/**/*"]}, "hello": "${Math.random() * 10000000}"}`); console.timeEnd('parse') } function test2() { console.time('parse'); const a = JSON.parse(`{"name":"sysserver","version":"2.0.4","description":"${Math.random() * 10000000}","main":"","scripts":{"start":"node dist/server.js","start-win":"${Math.random() * 10000000}","start:dev":"nodemon","======== BUILD =======":"","build_modules":"cd modules/s30-perco && node-gyp rebuild && cd ../ && cd s30-suprema && node-gyp rebuild && cd ../ && cd s30-video && node-gyp rebuild","package":"node ./scripts/build.js","package:local":"node ./scripts/build.js --build-type=local","clean":"node ./scripts/clean.js","pkg":"pkg -c package.json -t node16-win,node16-linux src/server.js --out-path build","pkg-arm":"pkg -c package.json -t node10.15.3-linux-armv7 dist/server.js --output build/pw-syssrv","======== DOCS =======":"","docs":"node scripts/docs.js","======== TEST =======":"","test":"mocha","lint":"eslint . --ext .ts"},"contributors":[],"dependencies":{"@grpc/grpc-js":"^1.3.6","@grpc/proto-loader":"^0.6.5","@protobufjs/aspromise":"^1.1.2","@types/log4js":"^2.3.5","binary-parser":"1.1.5","heapdump":"^0.3.15","ioredis":"^4.28.5","jpeg-js":"0.3.4","lodash.camelcase":"^4.3.0","log4js":"^6.3.0","long":"2.4.0","protobufjs":"^6.11.2","sax":"${Math.random() * 10000000}","smart-buffer":"1.0.3","underscore":"1.8.3","ws":"^8.3.0","xml2js":"0.4.19","xmlbuilder":"9.0.7"},"devDependencies":{"@PERCoWeb/eslint-config":"^1.1.0","@types/chai":"^4.2.22","@types/mocha":"^9.0.0","@types/node":"16.11.7","@types/sinon":"^10.0.9","chai":"^4.3.4","fs-extra":"^10.1.0","glob":"^7.2.0","mocha":"^9.2.0","nodemon":"^2.0.15","onvif":"file:./modules/onvif","rimraf":"^3.0.2","rtsp-ffmpeg":"0.0.11","s30-biosmart":"file:./modules/s30-biosmart","s30-perco":"file:./modules/s30-perco","s30-suprema":"file:./modules/s30-suprema","s30-video":"file:./modules/s30-video","sinon":"^13.0.0","ts-node":"^10.4.0","typedoc":"^0.22.10","typescript":"^4.5.2"},"pkg":{"scripts":["src/*.js","src/drivers/video/videoStream.js"],"assets":["axxon/**/*"]}, "hello": "${Math.random() * 10000000}"}`); console.timeEnd('parse') }
Tests:
test()
test();
test2()
test()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
test()
test2()
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down what's being tested on the provided JSON and explain the different approaches, their pros and cons, and other considerations. **Benchmark Definition** The benchmark definition is a JavaScript function `test()` (or `test2()` in the second test case) that creates a JSON string from an object. The object contains various properties, including dependencies, devDependencies, scripts, assets, and a "hello" property with a random value. **Individual Test Cases** There are two individual test cases: 1. `test()`: This test case calls the `test()` function. 2. `test2()`: This test case calls the `test2()` function. Both functions create a JSON string from the same object, but they might have slightly different execution paths due to differences in function call order or other optimizations. **HTML Preparation Code** There is no HTML preparation code provided for this benchmark. **Latest Benchmark Result** The latest benchmark result shows two sets of data for the two test cases: 1. `test2()`: Chrome 106 on a Windows Desktop with an executions per second (FPS) value of approximately 62,486. 2. `test()`: The same browser and platform as above, but with an FPS value of approximately 63,384. **What's being tested** The benchmark is testing the execution time of the two test cases, specifically: * How fast can the JavaScript engine execute the code? * Are there any differences in execution time between the two test cases? **Approaches** There are two approaches to creating the JSON string: 1. **Directly calling `test()` or `test2()`**: This approach executes the function directly and measures its execution time. 2. **Parsing a pre-generated JSON string**: Although not applicable here, some benchmarks might use pre-generated JSON strings and measure their parsing time. **Pros and Cons** Directly calling the functions has the advantage of being a more realistic test case, as it mimics how JavaScript code is executed in a real-world scenario. However, it may be slower due to the overhead of function call resolution. Parsing a pre-generated JSON string would be faster but might not accurately represent real-world use cases. **Other Considerations** * **Device and browser variability**: The benchmark result shows results for a specific device (Windows Desktop) and browser (Chrome 106). This suggests that the test is focused on optimizing the JavaScript engine's performance in this particular environment. * **Optimization techniques**: The benchmark might be using optimization techniques, such as caching or inlining, to improve performance.
Related benchmarks:
Lodash clone comparison vs JSON comparison
DeepClone vs JSON Stringify/Parse
json parse vs manual 3
json stringify vs object tostring number thresholds
Comments
Confirm delete:
Do you really want to delete benchmark?