Skip to content

Instantly share code, notes, and snippets.

@ruuda
Created February 15, 2016 20:57
Show Gist options
  • Save ruuda/225ef3349b229fa18820 to your computer and use it in GitHub Desktop.
Save ruuda/225ef3349b229fa18820 to your computer and use it in GitHub Desktop.
Benchmark Glium texture upload performance
#![feature(test)]
#[macro_use]
extern crate glium;
extern crate test;
use glium::DisplayBuild;
use glium::glutin;
fn fill_image() -> Vec<u8> {
let mut vec = Vec::with_capacity(1024 * 1024 * 4);
vec.resize(1024 * 1024 * 4, 0);
vec
}
#[bench]
fn bench_fill_texture(b: &mut test::Bencher) {
b.iter(|| {
test::black_box(fill_image());
});
}
#[bench]
fn bench_upload_texture(b: &mut test::Bencher) {
// building the display, ie. the main object
let display = glutin::WindowBuilder::new()
.with_vsync()
.build_glium()
.unwrap();
b.iter(|| {
let image: Vec<u8> = fill_image();
let image = glium::texture::RawImage2d::from_raw_rgba(image, ((1024, 1024)));
let texture = glium::Texture2d::new(&display, image).unwrap();
});
}
CPU: Intel® Core™ i7-6700HQ CPU @ 2.60GHz × 8
GPU: Intel® HD Graphics 530 (Skylake GT2)
Graphics driver: xf86-video-intel / mesa
running 2 tests
test bench_fill_texture ... bench: 690,454 ns/iter (+/- 123,167)
test bench_upload_texture ... bench: 3,653,785 ns/iter (+/- 2,256,557)
Conclusion: texture upload takes ~3 ms?!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment