Fix Rust GIF benchmark

The Rust GIF benchmark no longer compiles. The Cargo.toml file uses a
star to specify the gif crate version. That means a clean compile will
use the latest version even if it has breaking changes. Version 0.11 has
breaking changes which means the benchmark can no longer be compiled
from a clean start.

I fixed the benchmark by pinning the version to 0.11 and updating the
code to use the new API.
This commit is contained in:
Michael Mc Donnell committed 2022-01-14 11:01:11 -08:00
1 parent c104ae296c
commit d17fc6e6eb
2 files changed
+7 -9

No files matched your search

+1 -1
View File
@@ -4,5 +4,5 @@ version = "0.0.1"
authors = ["Nigel Tao <nigeltao@golang.org>"]
[dependencies]
gif = "*"
gif = "0.11"
rustc_version_runtime = "*"
+6 -8
View File
@@ -35,7 +35,6 @@
extern crate gif;
extern crate rustc_version_runtime;
use gif::SetParameter;
use std::time::Instant;
const ITERSCALE: u64 = 10;
@@ -183,15 +182,14 @@ fn bench(
// decode returns the number of bytes processed.
fn decode(dst: &mut [u8], src: &[u8], output_32_bit_color: bool) -> u64 {
let mut num_bytes = 0u64;
let mut decoder = gif::Decoder::new(src);
let mut options = gif::DecodeOptions::new();
if output_32_bit_color {
decoder.set(gif::ColorOutput::RGBA);
options.set_color_output(gif::ColorOutput::RGBA);
}
let mut reader = decoder.read_info().unwrap();
while let Some(_) = reader.next_frame_info().unwrap() {
num_bytes += reader.buffer_size() as u64;
reader.read_into_buffer(dst).unwrap();
let mut decoder = options.read_info(src).unwrap();
while let Some(_) = decoder.next_frame_info().unwrap() {
num_bytes += decoder.buffer_size() as u64;
decoder.read_into_buffer(dst).unwrap();
}
num_bytes
}