From bd62310634d30e1a59c1fc39732d72690e9e898b Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Wed, 4 Sep 2024 16:45:12 -0700 Subject: [PATCH] Added complex function to benchmark --- benches/benches/bevy_reflect/function.rs | 159 +++++++++++++++++++++++ 1 file changed, 159 insertions(+) diff --git a/benches/benches/bevy_reflect/function.rs b/benches/benches/bevy_reflect/function.rs index c46a43420d..92e5aee3fe 100644 --- a/benches/benches/bevy_reflect/function.rs +++ b/benches/benches/bevy_reflect/function.rs @@ -84,6 +84,20 @@ fn overload(c: &mut Criterion) { a + b } + fn complex( + _: T0, + _: T1, + _: T2, + _: T3, + _: T4, + _: T5, + _: T6, + _: T7, + _: T8, + _: T9, + ) { + } + c.benchmark_group("with_overload") .bench_function("01_overload", |b| { b.iter_batched( @@ -92,6 +106,15 @@ fn overload(c: &mut Criterion) { BatchSize::SmallInput, ); }) + .bench_function("01_complex_overload", |b| { + b.iter_batched( + || complex::.into_function(), + |func| { + func.with_overload(complex::) + }, + BatchSize::SmallInput, + ); + }) .bench_function("03_overload", |b| { b.iter_batched( || add::.into_function(), @@ -103,6 +126,17 @@ fn overload(c: &mut Criterion) { BatchSize::SmallInput, ); }) + .bench_function("03_complex_overload", |b| { + b.iter_batched( + || complex::.into_function(), + |func| { + func.with_overload(complex::) + .with_overload(complex::) + .with_overload(complex::) + }, + BatchSize::SmallInput, + ); + }) .bench_function("10_overload", |b| { b.iter_batched( || add::.into_function(), @@ -120,6 +154,23 @@ fn overload(c: &mut Criterion) { BatchSize::SmallInput, ); }) + .bench_function("10_complex_overload", |b| { + b.iter_batched( + || complex::.into_function(), + |func| { + func.with_overload(complex::) + .with_overload(complex::) + .with_overload(complex::) + .with_overload(complex::) + .with_overload(complex::) + .with_overload(complex::) + .with_overload(complex::) + .with_overload(complex::) + .with_overload(complex::) + }, + BatchSize::SmallInput, + ); + }) .bench_function("01_nested_overload", |b| { b.iter_batched( || add::.into_function(), @@ -181,6 +232,32 @@ fn overload(c: &mut Criterion) { BatchSize::SmallInput, ); }) + .bench_function("01_complex_overload", |b| { + b.iter_batched( + || { + ( + complex:: + .into_function() + .with_overload( + complex::, + ), + ArgList::new() + .push_owned(1_i8) + .push_owned(2_i16) + .push_owned(3_i32) + .push_owned(4_i64) + .push_owned(5_i128) + .push_owned(6_u8) + .push_owned(7_u16) + .push_owned(8_u32) + .push_owned(9_u64) + .push_owned(10_u128), + ) + }, + |(func, args)| func.call(args), + BatchSize::SmallInput, + ); + }) .bench_function("03_overload", |b| { b.iter_batched( || { @@ -197,6 +274,38 @@ fn overload(c: &mut Criterion) { BatchSize::SmallInput, ); }) + .bench_function("03_complex_overload", |b| { + b.iter_batched( + || { + ( + complex:: + .into_function() + .with_overload( + complex::, + ) + .with_overload( + complex::, + ) + .with_overload( + complex::, + ), + ArgList::new() + .push_owned(1_i32) + .push_owned(2_i64) + .push_owned(3_i128) + .push_owned(4_u8) + .push_owned(5_u16) + .push_owned(6_u32) + .push_owned(7_u64) + .push_owned(8_u128) + .push_owned(9_i8) + .push_owned(10_i16), + ) + }, + |(func, args)| func.call(args), + BatchSize::SmallInput, + ); + }) .bench_function("10_overload", |b| { b.iter_batched( || { @@ -218,6 +327,56 @@ fn overload(c: &mut Criterion) { |(func, args)| func.call(args), BatchSize::SmallInput, ); + }) + .bench_function("10_complex_overload", |b| { + b.iter_batched( + || { + ( + complex:: + .into_function() + .with_overload( + complex::, + ) + .with_overload( + complex::, + ) + .with_overload( + complex::, + ) + .with_overload( + complex::, + ) + .with_overload( + complex::, + ) + .with_overload( + complex::, + ) + .with_overload( + complex::, + ) + .with_overload( + complex::, + ) + .with_overload( + complex::, + ), + ArgList::new() + .push_owned(1_u8) + .push_owned(2_u16) + .push_owned(3_u32) + .push_owned(4_u64) + .push_owned(5_u128) + .push_owned(6_i8) + .push_owned(7_i16) + .push_owned(8_i32) + .push_owned(9_i64) + .push_owned(10_i128), + ) + }, + |(func, args)| func.call(args), + BatchSize::SmallInput, + ); }); }