Closed indiv0 closed 7 years ago
Currently this is not as fast as first loading the response into an in-memory string:
test tests::bench_xkcd ... bench: 18,558 ns/iter (+/- 5,447) test tests::bench_xkcd_bufreader ... bench: 58,496 ns/iter (+/- 13,621) test tests::bench_xkcd_reader ... bench: 368,452 ns/iter (+/- 145,628)
Where:
bench_xkcd
serde_json::from_str
bench_xkcd_reader
File
serde_json::from_reader
bench_xkcd_bufreader
BufReader
These results match with the results in this issue: https://github.com/serde-rs/json/issues/160
Seeing as xkcd JSON responses are typically very short, I won't introduce the performance penalty of using BufReader for now.
Currently this is not as fast as first loading the response into an in-memory string:
Where:
bench_xkcd
is the current code (i.e.serde_json::from_str
)bench_xkcd_reader
is parsing a response from aFile
usingserde_json::from_reader
bench_xkcd_bufreader
: same as above, but theFile
is also wrapped in aBufReader
These results match with the results in this issue: https://github.com/serde-rs/json/issues/160
Seeing as xkcd JSON responses are typically very short, I won't introduce the performance penalty of using
BufReader
for now.