Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
response.json() vs JSON.parse() testtest
(version: 0)
Comparing performance of:
testBlobJSON150() vs testBlobJSON35() vs testDataJSON150() vs testDataJSON35() vs testBlobParse150() vs testBlobParse35() vs testDataParse150() vs testDataParse35()
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script> const remote150kb = 'https://www.unpkg.com/tongwen@0.3.2/dict/ps2t.json' const remote35kb = 'https://www.unpkg.com/tongwen@0.3.2/dict/s2t.json' let blobUrl150kb = '' let blobUrl35kb = '' let dataUrl150kb = '' let dataUrl35kb = '' const throwError = () => { throw new Error('Not prepared') } let testBlobJSON150 = throwError let testBlobJSON35 = throwError let testDataJSON150 = throwError let testDataJSON35 = throwError let testBlobParse150 = throwError let testBlobParse35 = throwError let testDataParse150 = throwError let testDataParse35 = throwError const testBlobJSON150_ = async () => { const res = await fetch(blobUrl150kb) const json = await res.json() return json } const testBlobJSON35_ = async () => { const res = await fetch(blobUrl35kb) const json = await res.json() return json } const testDataJSON150_ = async () => { const res = await fetch(dataUrl150kb) const json = await res.json() return json } const testDataJSON35_ = async () => { const res = await fetch(dataUrl35kb) const json = await res.json() return json } const testBlobParse150_ = async () => { const res = await fetch(blobUrl150kb) const json = await res.text() return JSON.parse(json) } const testBlobParse35_ = async () => { const res = await fetch(blobUrl35kb) const json = await res.text() return JSON.parse(json) } const testDataParse150_ = async () => { const res = await fetch(dataUrl150kb) const json = await res.text() return JSON.parse(json) } const testDataParse35_ = async () => { const res = await fetch(dataUrl35kb) const json = await res.text() return JSON.parse(json) } const getJsonText = async (url) => { const res = await fetch(url) if (res.status !== 200) { throw new Error(`Status not 200: ${res.status}`) } // make sure it is json const json = await res.json() return JSON.stringify(json) } const toBlobUrl = (text) => { const blob = new Blob([text], { type: 'text/json' }) return URL.createObjectURL(blob) } const toDataUrl = (text) => { const url = encodeURIComponent(text) return `data:text/json,${url}` } const prepare = async () => { const [ text150kb, text35kb, ] = await Promise.all([ getJsonText(remote150kb), getJsonText(remote35kb) ]) dataUrl150kb = toDataUrl(text150kb) dataUrl35kb = toDataUrl(text35kb) blobUrl150kb = toBlobUrl(text150kb) blobUrl35kb = toBlobUrl(text35kb) testBlobJSON150 = testBlobJSON150_ testBlobJSON35 = testBlobJSON35_ testDataJSON150 = testDataJSON150_ testDataJSON35 = testDataJSON35_ testBlobParse150 = testBlobParse150_ testBlobParse35 = testBlobParse35_ testDataParse150 = testDataParse150_ testDataParse35 = testDataParse35_ } prepare() </script>
Tests:
testBlobJSON150()
testBlobJSON150()
testBlobJSON35()
testBlobJSON35()
testDataJSON150()
testDataJSON150()
testDataJSON35()
testDataJSON35()
testBlobParse150()
testBlobParse150()
testBlobParse35()
testBlobParse35()
testDataParse150()
testDataParse150()
testDataParse35()
testDataParse35()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (8)
Previous results
Fork
Test case name
Result
testBlobJSON150()
testBlobJSON35()
testDataJSON150()
testDataJSON35()
testBlobParse150()
testBlobParse35()
testDataParse150()
testDataParse35()
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):
Let's dive into the benchmark results! It appears that we have two sets of tests: `testBlobParse35()` and `testDataParse35()`, which are likely variants of the same test with different input data sizes. **Key findings:** 1. **`testBlobJSON35()`** has the highest execution rate (5051.759765625 executions per second) across all platforms, indicating that this test is relatively fast. 2. The `testDataParse35()` and `testBlobParse35()` tests are closely matched in terms of performance, with `testDataParse35()` being slightly faster (4747.74169921875 vs 4988.9248046875). 3. **`testBlobJSON150()`** has a significantly lower execution rate (2729.70068359375) compared to the other tests, suggesting that this test is less efficient. 4. The `testDataParse150()` and `testDataJSON150()` tests are also relatively slow (628.0831298828125 and 616.0164184570312 executions per second, respectively). **Conclusion:** Based on these benchmark results, it seems that the `testBlobJSON35()` test is a good candidate for optimization or refactoring to improve performance. The `testDataParse35()` and `testBlobParse35()` tests are relatively fast and may not require significant optimizations. However, further analysis of the codebase and input data distribution would be necessary to confirm these findings.
Related benchmarks:
JSON.parse() vs. js-yaml
JSON.parse() vs. js-yaml@3.13.1
JSON.parse vs fast-json-parse
js-yaml vs JSON.parse
JSON.parse vs object literal
Comments
Confirm delete:
Do you really want to delete benchmark?