Fps benchmark speed
Alphapage opened this issue · 5 comments
Hello,
The readme example below runs at approximatively 120fps on my Mac M1.
Can other processor perform better or is it a softbuffer limitation ?
Thank you in advance for your help.
use std::num::NonZeroU32;
use std::rc::Rc;
use winit::event::{Event, WindowEvent};
use winit::event_loop::{ControlFlow, EventLoop};
use winit::window::WindowBuilder;
fn main() {
let event_loop = EventLoop::new().unwrap();
let window = Rc::new(WindowBuilder::new().build(&event_loop).unwrap());
let context = softbuffer::Context::new(window.clone()).unwrap();
let mut surface = softbuffer::Surface::new(&context, window.clone()).unwrap();
event_loop
.run(move |event, elwt| {
elwt.set_control_flow(ControlFlow::Poll);
let tt = std::time::Instant::now();
let (width, height) = {
let size = window.inner_size();
(size.width, size.height)
};
surface
.resize(
NonZeroU32::new(width).unwrap(),
NonZeroU32::new(height).unwrap(),
)
.unwrap();
let mut buffer = surface.buffer_mut().unwrap();
for index in 0..(width * height) {
let y = index / width;
let x = index % width;
let red = x % 255;
let green = y % 255;
let blue = (x * y) % 255;
buffer[index as usize] = blue | (green << 8) | (red << 16);
}
buffer.present().unwrap();
println!("{}", 1.0 / tt.elapsed().as_secs_f64());
match event {
Event::WindowEvent {
window_id,
event: WindowEvent::RedrawRequested,
} if window_id == window.id() => {}
Event::WindowEvent {
event: WindowEvent::CloseRequested,
window_id,
} if window_id == window.id() => {
elwt.exit();
}
_ => {}
}
})
.unwrap();
}
Ok, great news...
But can you tell me what is the average performance on linux or windows, a pc can reach depending the cpu ?
Is it 1000fps , 10000fps , more ???
For Linux, I've personally benchmarked it to be around 600 FPS in the worst case. Not sure about other platforms; we use less efficient strategies for those.
Though if you get 600fps testing softbuffer, that will go down as soon as you have a software renderer doing non-trivial things. Which presumably would be the case for typical real uses.
Hopefully softbuffer won't be the bottleneck. But if you want the best performance you'll want OpenGL/Vulkan/Metal rather than a software renderer.
Yes it goes down very quickly by doing some trivial things too :(
Thank you for your expertise.