Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
decoding with JSON.decode and atob
(version: 0)
Comparing performance of:
decoding vs no decoding
Created:
9 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var encoded = []; var decoded = []; for (var i = 0; i < 500; i++) { decoded.push({"supports":{"moduleMove":true,"moduleDuplicate":true,"moduleDelete":true,"imageResize":true,"imageAlign":true,"imageCaption":true,"imageFullWidth":false},"fitsInContent":true,"alias":null,"isInSectionLoop":false,"imageId":Math.round(Math.random() * 10000),"imageAnimated":false,"imagePosition":1,"imageFit":true,"caption":"","link":"","linkTarget":"","imageAlt":"","linkTitle":"","iiePayload":{"zoom":2.0286,"cropXRatio":1,"cropYRatio":1,"version":1},"imageWidth":900,"imageHeight":382,"imageUrl":"https:\/\/diydev-shard01-cms.petsi.lan\/webseitendaten\/656\/563\/460\/images\/cache\/98.jpg?t=1475494410","origImageUrl":"https:\/\/diydev-shard01-cms.petsi.lan\/webseitendaten\/656\/563\/460\/images\/upload\/98.jpg?t=1475494410","origImageWidth":1600,"origImageHeight":1065,"transformedImageUrl":null,"transformedImageWidth":null,"transformedImageHeight":null,"imageMediaType":"JPEG","teaserboxWidth":900,"teaserboxHeight":700,"isFullwidth":false}); encoded.push(btoa(JSON.stringify(decoded[i]))); }
Tests:
decoding
for (var j = 0; j < encoded.length; j++) { console.log(JSON.parse(atob(encoded[j]))); }
no decoding
for (var k = 0; k < decoded.length; k++) { console.log(decoded[k]); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
decoding
no decoding
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0
Browser/OS:
Firefox 123 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
decoding
121.9 Ops/sec
no decoding
294.3 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the provided benchmark definition and explain what's being tested, compared, and their pros and cons. **Benchmark Definition** The provided JSON represents two individual test cases: 1. **"decoding"`**: This test case is testing how long it takes to decode a base64-encoded string using `atob` (base64 decoding function) and then parse the resulting string with `JSON.parse`. 2. **"no decoding"`**: This test case is testing how long it takes to simply log the `decoded` array, without any decoding or parsing. **Comparison** The two test cases are being compared in terms of their execution times: * "decoding": measures the time taken to decode a base64-encoded string and parse the resulting JSON object. * "no decoding": measures the time taken to simply log the `decoded` array (without decoding or parsing). **Options Compared** There are two main options being compared: 1. **Decoding using `atob` followed by parsing with `JSON.parse`**: This approach involves first encoding the `decoded` array as a base64 string using `btoa`, and then decoding it back to a JSON object using `atob`. 2. **Not decoding or parsing the data**: In this case, the `decoded` array is simply logged without any further processing. **Pros and Cons** 1. **Decoding using `atob` followed by parsing with `JSON.parse`**: * Pros: This approach ensures that the decoded string is in a format that can be easily used by JavaScript, as it's already in JSON format. * Cons: This approach introduces extra processing steps, which may increase execution time due to additional function calls and data conversions. 2. **Not decoding or parsing the data**: * Pros: This approach avoids introducing additional processing steps, which means shorter execution times for this specific test case. * Cons: The resulting `decoded` array is not in a format that can be easily used by JavaScript, as it's still in a binary format. **Library and Special JS Feature** In both test cases, the `JSON.parse()` function from the built-in `JSON` object library is used to parse JSON data. There are no special JavaScript features or syntax being tested. **Other Alternatives** If you wanted to compare alternative approaches for decoding base64-encoded strings, some options could be: * Using a custom base64 decoding implementation instead of `atob`. * Using a different decoding algorithm, such as binary-safe string encoding. * Comparing the performance of using `JSON.stringify()` and then parsing with `atob`, versus simply logging the decoded data. However, for this specific benchmark, the main focus is on comparing the execution times of two approaches: decoding using `atob` followed by parsing with `JSON.parse`, versus not decoding or parsing the data.
Related benchmarks:
decoding with JSON.decode and atob
drawImage: Copy from image or canvas
drawImage: Copy from image or canvas
Remove MIME type from encoded image URL
Comments
Confirm delete:
Do you really want to delete benchmark?