mapbox / geobuf

A compact binary encoding for geographic data.
ISC License
967 stars 84 forks source link

Decoding slower than JSON.parse() #114

Open espatial opened 4 years ago

espatial commented 4 years ago

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?

mourner commented 4 years ago

Interesting! Unfortunately there's no way for me to tell why it might be slower without a live test case I can reproduce.

segheysens commented 3 years ago

@espatial do you have a reproducible example I could dig into?