summaryrefslogtreecommitdiff
path: root/model/benches
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2025-12-08 19:56:48 -0500
committerMica White <botahamec@outlook.com>2025-12-08 19:56:48 -0500
commitfdb2804883deb31e3aeb15bbe588dcc9b7b76bd0 (patch)
treea4c51cd88664cab7b6673dcd3b425fb7a0202a38 /model/benches
parent93461aa9399d981db7d8611b3eb166636de4d971 (diff)
Diffstat (limited to 'model/benches')
-rwxr-xr-x[-rw-r--r--]model/benches/bitboard.rs182
1 files changed, 91 insertions, 91 deletions
diff --git a/model/benches/bitboard.rs b/model/benches/bitboard.rs
index 18d1a84..db70d65 100644..100755
--- a/model/benches/bitboard.rs
+++ b/model/benches/bitboard.rs
@@ -1,91 +1,91 @@
-use criterion::{black_box, criterion_group, criterion_main, Criterion};
-use model::CheckersBitBoard;
-use std::collections::hash_map::DefaultHasher;
-use std::hash::Hash;
-
-fn clone(c: &mut Criterion) {
- let board = CheckersBitBoard::starting_position();
- c.bench_function("clone", |b| b.iter(|| black_box(board)));
-}
-
-fn hash(c: &mut Criterion) {
- let board = CheckersBitBoard::starting_position();
- let mut hasher = DefaultHasher::new();
- c.bench_function("hash", |b| b.iter(|| board.hash(black_box(&mut hasher))));
-}
-
-fn default(c: &mut Criterion) {
- c.bench_function("default", |b| {
- b.iter(|| black_box(CheckersBitBoard::default()))
- });
-}
-
-fn eq(c: &mut Criterion) {
- let board1 = CheckersBitBoard::default();
- let board2 = CheckersBitBoard::default();
- c.bench_function("equal", |b| {
- b.iter(|| black_box(board1) == black_box(board2))
- });
-}
-
-fn default_const(c: &mut Criterion) {
- c.bench_function("default (const)", |b| {
- b.iter(|| black_box(CheckersBitBoard::starting_position()))
- });
-}
-
-fn piece_at(c: &mut Criterion) {
- let board = CheckersBitBoard::starting_position();
- c.bench_function("piece", |b| b.iter(|| board.piece_at(black_box(0))));
-}
-
-fn color_at_unchecked(c: &mut Criterion) {
- let board = CheckersBitBoard::starting_position();
- c.bench_function("color (unsafe)", |b| {
- b.iter(|| unsafe { board.color_at_unchecked(black_box(1)) })
- });
-}
-
-fn king_at_unchecked(c: &mut Criterion) {
- let board = CheckersBitBoard::starting_position();
- c.bench_function("king (unsafe)", |b| {
- b.iter(|| unsafe { board.king_at_unchecked(black_box(2)) })
- });
-}
-
-fn color_at(c: &mut Criterion) {
- let board = CheckersBitBoard::starting_position();
- c.bench_function("color (safe - filled)", |b| {
- b.iter(|| board.color_at(black_box(3)))
- });
-
- c.bench_function("color (safe - empty)", |b| {
- b.iter(|| board.color_at(black_box(2)))
- });
-}
-
-fn king_at(c: &mut Criterion) {
- let board = CheckersBitBoard::starting_position();
- c.bench_function("king (safe - filled)", |b| {
- b.iter(|| board.king_at(black_box(4)))
- });
-
- c.bench_function("king (safe - empty)", |b| {
- b.iter(|| board.king_at(black_box(9)))
- });
-}
-
-criterion_group!(
- bitboard,
- clone,
- hash,
- eq,
- default,
- default_const,
- piece_at,
- color_at_unchecked,
- king_at_unchecked,
- color_at,
- king_at,
-);
-criterion_main!(bitboard);
+use criterion::{black_box, criterion_group, criterion_main, Criterion};
+use model::CheckersBitBoard;
+use std::collections::hash_map::DefaultHasher;
+use std::hash::Hash;
+
+fn clone(c: &mut Criterion) {
+ let board = CheckersBitBoard::starting_position();
+ c.bench_function("clone", |b| b.iter(|| black_box(board)));
+}
+
+fn hash(c: &mut Criterion) {
+ let board = CheckersBitBoard::starting_position();
+ let mut hasher = DefaultHasher::new();
+ c.bench_function("hash", |b| b.iter(|| board.hash(black_box(&mut hasher))));
+}
+
+fn default(c: &mut Criterion) {
+ c.bench_function("default", |b| {
+ b.iter(|| black_box(CheckersBitBoard::default()))
+ });
+}
+
+fn eq(c: &mut Criterion) {
+ let board1 = CheckersBitBoard::default();
+ let board2 = CheckersBitBoard::default();
+ c.bench_function("equal", |b| {
+ b.iter(|| black_box(board1) == black_box(board2))
+ });
+}
+
+fn default_const(c: &mut Criterion) {
+ c.bench_function("default (const)", |b| {
+ b.iter(|| black_box(CheckersBitBoard::starting_position()))
+ });
+}
+
+fn piece_at(c: &mut Criterion) {
+ let board = CheckersBitBoard::starting_position();
+ c.bench_function("piece", |b| b.iter(|| board.piece_at(black_box(0))));
+}
+
+fn color_at_unchecked(c: &mut Criterion) {
+ let board = CheckersBitBoard::starting_position();
+ c.bench_function("color (unsafe)", |b| {
+ b.iter(|| unsafe { board.color_at_unchecked(black_box(1)) })
+ });
+}
+
+fn king_at_unchecked(c: &mut Criterion) {
+ let board = CheckersBitBoard::starting_position();
+ c.bench_function("king (unsafe)", |b| {
+ b.iter(|| unsafe { board.king_at_unchecked(black_box(2)) })
+ });
+}
+
+fn color_at(c: &mut Criterion) {
+ let board = CheckersBitBoard::starting_position();
+ c.bench_function("color (safe - filled)", |b| {
+ b.iter(|| board.color_at(black_box(3)))
+ });
+
+ c.bench_function("color (safe - empty)", |b| {
+ b.iter(|| board.color_at(black_box(2)))
+ });
+}
+
+fn king_at(c: &mut Criterion) {
+ let board = CheckersBitBoard::starting_position();
+ c.bench_function("king (safe - filled)", |b| {
+ b.iter(|| board.king_at(black_box(4)))
+ });
+
+ c.bench_function("king (safe - empty)", |b| {
+ b.iter(|| board.king_at(black_box(9)))
+ });
+}
+
+criterion_group!(
+ bitboard,
+ clone,
+ hash,
+ eq,
+ default,
+ default_const,
+ piece_at,
+ color_at_unchecked,
+ king_at_unchecked,
+ color_at,
+ king_at,
+);
+criterion_main!(bitboard);