1use orbclient::{Color, EventOption, Renderer, Window};
4
5macro_rules! time {
6 ($msg:tt, $block: block) => {{
7 let _time_instant = ::std::time::Instant::now();
8 for _ in (0..100) {
9 $block
10 }
11 let _time_duration = _time_instant.elapsed();
12 let _time_fractional =
13 _time_duration.as_secs() as f64 + (_time_duration.subsec_nanos() as f64) / 1000000000.0;
14 println!("{}: {} ms", $msg, _time_fractional * 1000.0);
15 }};
16}
17
18fn main() {
19 let mut window = Window::new(10, 10, 1000, 800, "RECTANGLE BENCHMARK").unwrap();
20
21 let alpha = 250;
22
23 time!("set", { window.set(Color::rgb(255, 255, 255)) });
24
25 time!("rect 800x800", {
26 window.rect(0, 0, 800, 800, Color::rgba(0, 0, 255, alpha))
27 });
28
29 time!("rect 400x400", {
30 window.rect(0, 0, 400, 400, Color::rgba(0, 255, 0, alpha))
31 });
32
33 time!("rect 200x200", {
34 window.rect(0, 0, 200, 200, Color::rgba(255, 0, 0, alpha))
35 });
36
37 time!("sync", {
38 window.update();
39 });
40
41 'events: loop {
42 for event in window.events() {
43 #[allow(clippy::single_match)]
44 match event.to_option() {
45 EventOption::Quit(_quit_event) => break 'events,
46 _ => (),
47 }
48 }
49 }
50}