Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4 #21

Merged
merged 12 commits into from
Feb 7, 2024
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[package]
name = "dez80"
version = "3.0.1"
description = "A Z80 disassembly library."
version = "4.0.0"
description = "A Z80 instruction decoding and (dis)assembly library."
repository = "https://github.com/rzumer/dez80"
authors = ["Raphaël Zumer <[email protected]>"]
license = "MIT"
edition = "2021"

[dependencies]
strum = "0.19"
strum_macros = "0.19"
strum = "0.26"
strum_macros = "0.26"

[dev-dependencies]
criterion = "0.3"
rayon = "1.4"
criterion = "0.5"
rayon = "1.8"

[[bench]]
name = "bench"
Expand Down
26 changes: 10 additions & 16 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
#[macro_use]
extern crate criterion;

use criterion::{Bencher, Criterion, Fun};
use criterion::{Bencher, Criterion};
use dez80::Instruction;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};

const INSTRUCTION_STREAM: &[u8] = include_bytes!("../tests/allinstructions.bin");

fn bench_instruction_from_bytes(c: &mut Criterion) {
c.bench_function("Instruction::from_bytes", |b| {
b.iter(|| Instruction::decode_all(&mut INSTRUCTION_STREAM))
b.iter(|| Instruction::decode_all(&mut &INSTRUCTION_STREAM[..]))
});
}

Expand All @@ -24,17 +24,14 @@ fn bench_instruction_to_bytes(c: &mut Criterion) {
b.iter(|| instructions.par_iter().flat_map(|i| i.to_bytes()).collect::<Vec<u8>>())
}

let sequential_operations = Fun::new("Sequential", bench_sequential);
let parallel_operations = Fun::new("Parallel", bench_parallel);

let funs = vec![sequential_operations, parallel_operations];
let mut instructions = Instruction::decode_all(&mut INSTRUCTION_STREAM);

let mut instructions = Instruction::decode_all(&mut &INSTRUCTION_STREAM[..]);
while instructions.len() < 1024 {
instructions.append(&mut instructions.clone());
}

c.bench_functions("Instruction::to_bytes", funs, instructions);
let mut bench_group = c.benchmark_group("Instruction::to_bytes");
bench_group.bench_with_input("Sequential", &instructions, bench_sequential);
bench_group.bench_with_input("Parallel", &instructions, bench_parallel);
}

fn bench_instruction_to_string(c: &mut Criterion) {
Expand All @@ -46,17 +43,14 @@ fn bench_instruction_to_string(c: &mut Criterion) {
b.iter(|| instructions.par_iter().map(|i| i.to_string()).collect::<Vec<String>>())
}

let sequential_operations = Fun::new("Sequential", bench_sequential);
let parallel_operations = Fun::new("Parallel", bench_parallel);

let funs = vec![sequential_operations, parallel_operations];
let mut instructions = Instruction::decode_all(&mut INSTRUCTION_STREAM);

let mut instructions = Instruction::decode_all(&mut &INSTRUCTION_STREAM[..]);
while instructions.len() < 1024 {
instructions.append(&mut instructions.clone());
}

c.bench_functions("Instruction::to_string", funs, instructions);
let mut bench_group = c.benchmark_group("Instruction::to_string");
bench_group.bench_with_input("Sequential", &instructions, bench_sequential);
bench_group.bench_with_input("Parallel", &instructions, bench_parallel);
}

criterion_group!(
Expand Down
Loading
Loading