mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-20 04:00:01 +00:00
Refactor benchmarks to use a constant for sizes
This commit is contained in:
parent
b758b22b93
commit
894b85b384
@ -1,7 +1,7 @@
|
|||||||
// Combined benchmarks for rustframe
|
// Combined benchmarks
|
||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
// Import Duration for measurement_time and warm_up_time
|
|
||||||
use rustframe::{
|
use rustframe::{
|
||||||
frame::{Frame, RowIndex},
|
frame::{Frame, RowIndex},
|
||||||
matrix::{BoolMatrix, Matrix},
|
matrix::{BoolMatrix, Matrix},
|
||||||
@ -9,8 +9,6 @@ use rustframe::{
|
|||||||
};
|
};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
// You can define a custom Criterion configuration function
|
|
||||||
// This will be passed to the criterion_group! macro
|
|
||||||
pub fn for_short_runs() -> Criterion {
|
pub fn for_short_runs() -> Criterion {
|
||||||
Criterion::default()
|
Criterion::default()
|
||||||
// (samples != total iterations)
|
// (samples != total iterations)
|
||||||
@ -20,14 +18,15 @@ pub fn for_short_runs() -> Criterion {
|
|||||||
.measurement_time(Duration::from_millis(2000))
|
.measurement_time(Duration::from_millis(2000))
|
||||||
// reduce warm-up time as well for faster overall run
|
// reduce warm-up time as well for faster overall run
|
||||||
.warm_up_time(Duration::from_millis(50))
|
.warm_up_time(Duration::from_millis(50))
|
||||||
// You could also make it much shorter if needed, e.g., 50ms measurement, 100ms warm-up
|
// can make it much shorter if needed, e.g., 50ms measurement, 100ms warm-up
|
||||||
// .measurement_time(Duration::from_millis(50))
|
// .measurement_time(Duration::from_millis(50))
|
||||||
// .warm_up_time(Duration::from_millis(100))
|
// .warm_up_time(Duration::from_millis(100))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const BENCH_SIZES: [usize; 5] = [1, 100, 250, 500, 1000];
|
||||||
|
|
||||||
fn bool_matrix_operations_benchmark(c: &mut Criterion) {
|
fn bool_matrix_operations_benchmark(c: &mut Criterion) {
|
||||||
let sizes = [1, 100, 1000];
|
let sizes = BENCH_SIZES;
|
||||||
// let sizes = [1000];
|
|
||||||
|
|
||||||
for &size in &sizes {
|
for &size in &sizes {
|
||||||
let data1: Vec<bool> = (0..size * size).map(|x| x % 2 == 0).collect();
|
let data1: Vec<bool> = (0..size * size).map(|x| x % 2 == 0).collect();
|
||||||
@ -62,8 +61,7 @@ fn bool_matrix_operations_benchmark(c: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn matrix_boolean_operations_benchmark(c: &mut Criterion) {
|
fn matrix_boolean_operations_benchmark(c: &mut Criterion) {
|
||||||
let sizes = [1, 100, 1000];
|
let sizes = BENCH_SIZES;
|
||||||
// let sizes = [1000];
|
|
||||||
|
|
||||||
for &size in &sizes {
|
for &size in &sizes {
|
||||||
let data1: Vec<bool> = (0..size * size).map(|x| x % 2 == 0).collect();
|
let data1: Vec<bool> = (0..size * size).map(|x| x % 2 == 0).collect();
|
||||||
@ -98,8 +96,7 @@ fn matrix_boolean_operations_benchmark(c: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn matrix_operations_benchmark(c: &mut Criterion) {
|
fn matrix_operations_benchmark(c: &mut Criterion) {
|
||||||
let sizes = [1, 100, 1000];
|
let sizes = BENCH_SIZES;
|
||||||
// let sizes = [1000];
|
|
||||||
|
|
||||||
for &size in &sizes {
|
for &size in &sizes {
|
||||||
let data: Vec<f64> = (0..size * size).map(|x| x as f64).collect();
|
let data: Vec<f64> = (0..size * size).map(|x| x as f64).collect();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user