Вопрос

I'm just wondering if d3.text is faster than d3.json?

The reason behind my question is that I'm reading the source code behind cubism.js and I'm just curious to know if it's done with d3.text because it's faster?

Это было полезно?

Решение

Not really.

The reason the graphic metric uses d3.text is because Graphite doesn’t reply with JSON-formatted data; it has its own raw format. Cubism does use d3.json when the server replies with JSON, as for example with cube metrics.

Under the hood, both d3.text and d3.json both use d3.xhr, so they are going to download the file exactly the same way (via asynchronous XMLHttpRequest). Sure, d3.text doesn’t subsequently run the response through JSON.parse, but you still have to parse the reply somehow. And more often than not I would expect the native JSON.parse to be faster, though it would depend on the exact format.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top