rhai/benches/engine.rs

40 lines
811 B
Rust
Raw Normal View History

2020-04-19 12:33:09 +02:00
#![feature(test)]
///! Test evaluating expressions
extern crate test;
use rhai::{Array, CorePackage, Engine, Map, Package, RegisterFn, INT};
2020-04-19 12:33:09 +02:00
use test::Bencher;
#[bench]
fn bench_engine_new(bench: &mut Bencher) {
bench.iter(|| Engine::new());
}
#[bench]
fn bench_engine_new_raw(bench: &mut Bencher) {
bench.iter(|| Engine::new_raw());
}
#[bench]
fn bench_engine_new_raw_core(bench: &mut Bencher) {
let package = CorePackage::new();
bench.iter(|| {
let mut engine = Engine::new_raw();
engine.load_package(package.get());
});
}
2020-04-19 12:33:09 +02:00
#[bench]
fn bench_engine_register_fn(bench: &mut Bencher) {
fn hello(a: INT, b: Array, c: Map) -> bool {
true
}
bench.iter(|| {
let mut engine = Engine::new();
engine.register_fn("hello", hello);
});
}