|
|
@ -1,16 +1,5 @@ |
|
|
|
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
|
|
|
|
use gntag::agent::{Agent, SimpleAgent};
|
|
|
|
use gntag::world::ActualWorld;
|
|
|
|
|
|
|
|
fn get_world(width: isize, spacing: usize, validate: bool) -> ActualWorld {
|
|
|
|
let mut agents = vec![];
|
|
|
|
for x in (0..width).step_by(spacing) {
|
|
|
|
for y in (0..width).step_by(spacing) {
|
|
|
|
agents.push(((x, y).into(), Box::new(SimpleAgent) as Box<dyn Agent>));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ActualWorld::new((width, width).into(), agents, validate)
|
|
|
|
}
|
|
|
|
use gntag::get_world;
|
|
|
|
|
|
|
|
fn world(c: &mut Criterion) {
|
|
|
|
let mut group = c.benchmark_group("world");
|
|
|
@ -21,7 +10,7 @@ fn world(c: &mut Criterion) { |
|
|
|
BenchmarkId::new("validating", spacing),
|
|
|
|
&spacing,
|
|
|
|
|b, &spacing| {
|
|
|
|
let mut world = get_world(width, spacing as usize, true);
|
|
|
|
let mut world = get_world(width, width, spacing as usize, true);
|
|
|
|
b.iter(|| world.do_step());
|
|
|
|
},
|
|
|
|
);
|
|
|
@ -29,7 +18,7 @@ fn world(c: &mut Criterion) { |
|
|
|
BenchmarkId::new("non-validating", spacing),
|
|
|
|
&spacing,
|
|
|
|
|b, &spacing| {
|
|
|
|
let mut world = get_world(width, spacing as usize, false);
|
|
|
|
let mut world = get_world(width, width, spacing as usize, false);
|
|
|
|
b.iter(|| world.do_step());
|
|
|
|
},
|
|
|
|
);
|
|
|
|