indiv0 / xkcd-rs

Rust bindings for the XKCD web API
https://indiv0.github.io/xkcd-rs/xkcd
Apache License 2.0
4 stars 0 forks source link

Simplify code with `serde_json::from_reader` #2

Closed indiv0 closed 7 years ago

indiv0 commented 8 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:

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.