[go: up one dir, main page]

pistoncore-input 0.3.0

A structure for user input

#![feature(test)]

extern crate test;
extern crate input;

use test::Bencher;
use input::{
    Event,
    Input,
    Motion,
    MouseScrollEvent,
    MouseRelativeEvent,
    MouseCursorEvent
};

#[bench]
fn bench_input_mouse_cursor(bencher: &mut Bencher) {
    let e = Input::Move(Motion::MouseCursor(0.0, 0.0));
    bencher.iter(|| {
        let _: Option<Input> = MouseCursorEvent::from_xy(1.0, 0.0, &e);
    });
}

#[bench]
fn bench_event_mouse_cursor(bencher: &mut Bencher) {
    let e = Event::Input(Input::Move(Motion::MouseCursor(0.0, 0.0)));
    bencher.iter(|| {
        let _: Option<Event> = MouseCursorEvent::from_xy(1.0, 0.0, &e);
    });
}

#[bench]
fn bench_input_mouse_relative(bencher: &mut Bencher) {
    let e = Input::Move(Motion::MouseRelative(0.0, 0.0));
    bencher.iter(|| {
        let _: Option<Input> = MouseRelativeEvent::from_xy(1.0, 0.0, &e);
    });
}

#[bench]
fn bench_event_mouse_relative(bencher: &mut Bencher) {
    let e = Event::Input(Input::Move(Motion::MouseRelative(0.0, 0.0)));
    bencher.iter(|| {
        let _: Option<Event> = MouseRelativeEvent::from_xy(1.0, 0.0, &e);
    });
}

#[bench]
fn bench_input_mouse_scroll(bencher: &mut Bencher) {
    let e = Input::Move(Motion::MouseScroll(0.0, 0.0));
    bencher.iter(|| {
        let _: Option<Input> = MouseScrollEvent::from_xy(1.0, 0.0, &e);
    });
}

#[bench]
fn bench_event_mouse_scroll(bencher: &mut Bencher) {
    let e = Event::Input(Input::Move(Motion::MouseScroll(0.0, 0.0)));
    bencher.iter(|| {
        let _: Option<Event> = MouseScrollEvent::from_xy(1.0, 0.0, &e);
    });
}