Decoding slower than JSON.parse()
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 86
- PR merge metrics
- No merged PRs in 30d
Description
I am loading a geojson file of full US Zipcodes over an ajax request, before I was using plain json, I now change it to use geobuf. So I replace the JSON.parse() by a geobuf.decode().
The document says it should be faster:
even faster than native JSON parse/stringify.
However now it is actualy 2 seconds slower.
var req = new XMLHttpRequest();
req.responseType = "arraybuffer";
req.addEventListener("load", function () {
//var featureCollection = JSON.parse(this.responseText); // Took arround 4s
var featureCollection = geobuf.decode(new Pbf(this.response)); // takes arround 6s
//...
});
req.open("GET", url);
req.send();
Am I doing something wrong or is there any way to improve it?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the XMLHttpRequest example in the issue, comparing JSON.parse(this.responseText) with geobuf.decode(new Pbf(this.response)) on the full US Zipcodes GeoJSON. Trace the decode entry point and benchmark both paths to determine whether the slowdown is reproducible and what work would be needed to improve or explain it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100