From 5ec77c156ca7e3365e476459d6d958635495e549 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 9 Oct 2023 21:35:34 +0200 Subject: [PATCH 1/2] get benchmarks type checking again --- crates/bench/benches/generic.rs | 6 +++--- crates/bench/benches/special.rs | 15 ++++----------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/crates/bench/benches/generic.rs b/crates/bench/benches/generic.rs index 8a350c5d570..b2f88782267 100644 --- a/crates/bench/benches/generic.rs +++ b/crates/bench/benches/generic.rs @@ -294,9 +294,9 @@ fn _filter_setup( buckets: u32, ) -> ResultBench<(String, TableSchema, Vec)> { let filter_column_type = match &T::product_type().elements[column_index as usize].algebraic_type { - AlgebraicType::String => "string", - AlgebraicType::U32 => "u32", - AlgebraicType::U64 => "u64", + &AlgebraicType::String => "string", + &AlgebraicType::U32 => "u32", + &AlgebraicType::U64 => "u64", _ => unimplemented!(), }; let mean_result_count = load / buckets; diff --git a/crates/bench/benches/special.rs b/crates/bench/benches/special.rs index 4c692e284b4..9b20865786f 100644 --- a/crates/bench/benches/special.rs +++ b/crates/bench/benches/special.rs @@ -4,10 +4,7 @@ use spacetimedb_bench::{ schemas::{create_sequential, BenchTable, Location, Person, RandomTable}, spacetime_module::BENCHMARKS_MODULE, }; -use spacetimedb_lib::{ - sats::{self, BuiltinValue}, - AlgebraicValue, ProductValue, -}; +use spacetimedb_lib::{sats, ProductValue}; use spacetimedb_testing::modules::start_runtime; fn criterion_benchmark(c: &mut Criterion) { @@ -26,9 +23,7 @@ fn custom_module_benchmarks(c: &mut Criterion) { }; let module = runtime.block_on(async { BENCHMARKS_MODULE.load_module(config).await }); - let args = ProductValue { - elements: vec![AlgebraicValue::Builtin(BuiltinValue::String("0".repeat(65536)))], - }; + let args = sats::product!["0".repeat(65536)]; c.bench_function("stdb_module/large_arguments/64KiB", |b| { b.iter_batched( || args.clone(), @@ -37,10 +32,8 @@ fn custom_module_benchmarks(c: &mut Criterion) { ) }); - for n in [1, 100, 1000] { - let args = ProductValue { - elements: vec![AlgebraicValue::Builtin(BuiltinValue::U32(n))], - }; + for n in [1u32, 100, 1000] { + let args = sats::product![n]; c.bench_function(&format!("stdb_module/print_bulk/lines={n}"), |b| { b.iter_batched( || args.clone(), From 8b300f9b049089502e9329ea0dbe0edf7944df21 Mon Sep 17 00:00:00 2001 From: Tyler Cloutier Date: Mon, 9 Oct 2023 18:25:35 -0700 Subject: [PATCH 2/2] Fixed clippy warning --- crates/bench/benches/generic.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bench/benches/generic.rs b/crates/bench/benches/generic.rs index b2f88782267..84fb4b3af91 100644 --- a/crates/bench/benches/generic.rs +++ b/crates/bench/benches/generic.rs @@ -293,10 +293,10 @@ fn _filter_setup( load: u32, buckets: u32, ) -> ResultBench<(String, TableSchema, Vec)> { - let filter_column_type = match &T::product_type().elements[column_index as usize].algebraic_type { - &AlgebraicType::String => "string", - &AlgebraicType::U32 => "u32", - &AlgebraicType::U64 => "u64", + let filter_column_type = match T::product_type().elements[column_index as usize].algebraic_type { + AlgebraicType::String => "string", + AlgebraicType::U32 => "u32", + AlgebraicType::U64 => "u64", _ => unimplemented!(), }; let mean_result_count = load / buckets;