mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 16:47:28 +01:00
Add some more Go and Rust GIF benchmarks
On my machine (Debian Testing as of November 2017, Intel x86_64 Broadwell): Rust 28.0 rustc 1.14 github.com/Geal/gif.rs Rust 29.1 rustc 1.14 github.com/PistonDevelopers/image-gif Go 62.7 go 1.9 standard library's image/gif C 97.3 giflib 5.1 from Debian Testing's /usr/lib Wuffs 123 clang 5.0 Wuffs 136 gcc 7.2 Numbers are megabytes per second, equivalent to megapixels per second for GIF images.
This commit is contained in:
1 parent
5ebc62e7da
commit
9a463d4675
4 files changed
+222
-7
No files matched your search
@@ -12,16 +12,36 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// This program exercises the Rust GIF decoder in https://github.com/Geal/gif.rs
|
||||
// This program exercises the Rust GIF decoder at
|
||||
// https://github.com/Geal/gif.rs
|
||||
//
|
||||
// Wuffs doesn't depend on Rust or Nom (a parser combinator library written in
|
||||
// Rust) per se, but this program gives some comparitive data on how fast a
|
||||
// Rust GIF decoder could perform.
|
||||
// Wuffs' C code doesn't depend on Rust or Nom (a parser combinator library
|
||||
// written in Rust) per se, but this program gives some performance data for
|
||||
// specific Rust GIF implementations. The equivalent Wuffs benchmarks (on the
|
||||
// same test image) are run via:
|
||||
//
|
||||
// wuffs bench -mimic -focus=wuffs_gif_decode_1000k,mimic_gif_decode_1000k std/gif
|
||||
//
|
||||
// The "1000k" is because the test image (harvesters.gif) has approximately 1
|
||||
// million pixels.
|
||||
//
|
||||
// The Wuffs benchmark reports megabytes per second. This program reports
|
||||
// megapixels per second. The two concepts should be equivalent, since GIF
|
||||
// images' pixel data are always 1 byte per pixel indices into a color palette.
|
||||
// However, the gif.rs library only lets you decode 3 bytes per pixel (RGB),
|
||||
// not 1 byte per pixel. This automatic palette look-up is arguably a defect in
|
||||
// its API: decoding a 1,000 × 1,000 pixel image requires (2,000,000 - 768)
|
||||
// more bytes this way, per frame, and animated GIFs have multiple frames.
|
||||
//
|
||||
// To run this program, do "cargo run --release > /dev/null" from the parent
|
||||
// directory (the directory containing the Cargo.toml file). See the eprint
|
||||
// comment below for why we redirect to /dev/null.
|
||||
|
||||
// TODO: unify this program, bench-rust-gif-dot-rs, with bench-rust-gif, the
|
||||
// other Rust GIF benchmark program. They are two separate programs because
|
||||
// both libraries want to be named "gif", and the cargo package manager cannot
|
||||
// handle duplicate names (https://github.com/rust-lang/cargo/issues/1311).
|
||||
|
||||
extern crate gif;
|
||||
|
||||
use std::time::Instant;
|
||||
@@ -62,7 +82,7 @@ fn main() {
|
||||
// https://github.com/Geal/gif.rs/issues/4). When running this program, it
|
||||
// can be useful to redirect stdout (but not stderr) to /dev/null.
|
||||
eprint!(
|
||||
"{}.{:03} megapixels/second\n",
|
||||
"gif.rs {:3}.{:03} megapixels/second github.com/Geal/gif.rs\n",
|
||||
kp_per_s / 1_000,
|
||||
kp_per_s % 1_000
|
||||
);
|
||||
@@ -70,8 +90,8 @@ fn main() {
|
||||
|
||||
fn decode(dst: &mut [u8], src: &[u8]) {
|
||||
// Set up the hard-coded sanity check, executed below.
|
||||
dst[0] = 0;
|
||||
dst[NUM_BYTES - 1] = 0;
|
||||
dst[0] = 0xFE;
|
||||
dst[NUM_BYTES - 1] = 0xFE;
|
||||
|
||||
let (_, colors) =
|
||||
gif::parser::color_table(&src[COLOR_TABLE_OFFSET..], COLOR_TABLE_ELEMENT_COUNT).unwrap();
|
||||
|
||||
Reference in new issue
Block a user