diff --git a/leptos_reactive/Cargo.toml b/leptos_reactive/Cargo.toml index 5abbb48cb..798534517 100644 --- a/leptos_reactive/Cargo.toml +++ b/leptos_reactive/Cargo.toml @@ -48,10 +48,6 @@ pin-project = "1" paste = "1" [dev-dependencies] -criterion = { version = "0.5.1", features = ["html_reports"] } -reactive-signals = { version = "0.1.0-alpha.4", features = ["profile"] } -l021 = { package = "leptos", version = "0.2.1" } -sycamore = { version = "0.8", features = ["ssr"] } log = "0.4" tokio-test = "0.4" leptos = { path = "../leptos" } @@ -121,15 +117,3 @@ skip_feature_sets = [ "rkyv", ], ] - -[[bench]] -name = "deep_update" -harness = false - -[[bench]] -name = "fan_out" -harness = false - -[[bench]] -name = "narrow_down" -harness = false diff --git a/leptos_reactive/benches/deep_update.rs b/leptos_reactive/benches/deep_update.rs deleted file mode 100644 index a4c309939..000000000 --- a/leptos_reactive/benches/deep_update.rs +++ /dev/null @@ -1,110 +0,0 @@ -use criterion::{criterion_group, criterion_main, Criterion}; - -fn rs_deep_update(c: &mut Criterion) { - use reactive_signals::{ - runtimes::ClientRuntime, signal, types::Func, Signal, - }; - - c.bench_function("rs_deep_update", |b| { - b.iter(|| { - let sc = ClientRuntime::bench_root_scope(); - let signal = signal!(sc, 0); - let mut memos = Vec::, ClientRuntime>>::new(); - for i in 0..1000usize { - let prev = memos.get(i.saturating_sub(1)).copied(); - if let Some(prev) = prev { - memos.push(signal!(sc, move || prev.get() + 1)) - } else { - memos.push(signal!(sc, move || signal.get() + 1)) - } - } - signal.set(1); - assert_eq!(memos[999].get(), 1001); - }); - }); -} - -fn l021_deep_update(c: &mut Criterion) { - use l021::*; - - c.bench_function("l021_deep_update", |b| { - let runtime = create_runtime(); - b.iter(|| { - create_scope(runtime, |cx| { - let signal = create_rw_signal(cx, 0); - let mut memos = Vec::>::new(); - for i in 0..1000usize { - let prev = memos.get(i.saturating_sub(1)).copied(); - if let Some(prev) = prev { - memos.push(create_memo(cx, move |_| prev.get() + 1)); - } else { - memos.push(create_memo(cx, move |_| signal.get() + 1)); - } - } - signal.set(1); - assert_eq!(memos[999].get(), 1001); - }) - .dispose() - }); - runtime.dispose(); - }); -} - -fn sycamore_deep_update(c: &mut Criterion) { - use sycamore::reactive::*; - - c.bench_function("sycamore_deep_update", |b| { - b.iter(|| { - let d = create_scope(|cx| { - let signal = create_signal(cx, 0); - let mut memos = Vec::<&ReadSignal>::new(); - for i in 0..1000usize { - let prev = memos.get(i.saturating_sub(1)).copied(); - if let Some(prev) = prev { - memos.push(create_memo(cx, move || *prev.get() + 1)); - } else { - memos.push(create_memo(cx, move || *signal.get() + 1)); - } - } - signal.set(1); - assert_eq!(*memos[999].get(), 1001); - }); - unsafe { d.dispose() }; - }); - }); -} - -fn leptos_deep_update(c: &mut Criterion) { - use leptos::*; - let runtime = create_runtime(); - - c.bench_function("leptos_deep_update", |b| { - b.iter(|| { - create_scope(runtime, |cx| { - let signal = create_rw_signal(cx, 0); - let mut memos = Vec::>::new(); - for i in 0..1000usize { - let prev = memos.get(i.saturating_sub(1)).copied(); - if let Some(prev) = prev { - memos.push(create_memo(cx, move |_| prev.get() + 1)); - } else { - memos.push(create_memo(cx, move |_| signal.get() + 1)); - } - } - signal.set(1); - assert_eq!(memos[999].get(), 1001); - }) - .dispose() - }); - }); - runtime.dispose(); -} - -criterion_group!( - deep, - rs_deep_update, - l021_deep_update, - sycamore_deep_update, - leptos_deep_update -); -criterion_main!(deep); diff --git a/leptos_reactive/benches/fan_out.rs b/leptos_reactive/benches/fan_out.rs deleted file mode 100644 index c9b1cf6b9..000000000 --- a/leptos_reactive/benches/fan_out.rs +++ /dev/null @@ -1,91 +0,0 @@ -use criterion::{criterion_group, criterion_main, Criterion}; - -fn rs_fan_out(c: &mut Criterion) { - use reactive_signals::{runtimes::ClientRuntime, signal}; - - c.bench_function("rs_fan_out", |b| { - b.iter(|| { - let cx = ClientRuntime::bench_root_scope(); - let sig = signal!(cx, 0); - let memos = (0..1000) - .map(|_| signal!(cx, move || sig.get())) - .collect::>(); - assert_eq!(memos.iter().map(|m| m.get()).sum::(), 0); - sig.set(1); - assert_eq!(memos.iter().map(|m| m.get()).sum::(), 1000); - }); - }); -} - -fn l021_fan_out(c: &mut Criterion) { - use l021::*; - - c.bench_function("l021_fan_out", |b| { - let runtime = create_runtime(); - b.iter(|| { - create_scope(runtime, |cx| { - let sig = create_rw_signal(cx, 0); - let memos = (0..1000) - .map(|_| create_memo(cx, move |_| sig.get())) - .collect::>(); - assert_eq!(memos.iter().map(|m| m.get()).sum::(), 0); - sig.set(1); - assert_eq!(memos.iter().map(|m| m.get()).sum::(), 1000); - }) - .dispose() - }); - runtime.dispose(); - }); -} - -fn sycamore_fan_out(c: &mut Criterion) { - use sycamore::reactive::*; - - c.bench_function("sycamore_fan_out", |b| { - b.iter(|| { - let d = create_scope(|cx| { - let sig = create_signal(cx, 0); - let memos = (0..1000) - .map(|_| create_memo(cx, move || sig.get())) - .collect::>(); - assert_eq!(memos.iter().map(|m| *(*m.get())).sum::(), 0); - sig.set(1); - assert_eq!( - memos.iter().map(|m| *(*m.get())).sum::(), - 1000 - ); - }); - unsafe { d.dispose() }; - }); - }); -} - -fn leptos_fan_out(c: &mut Criterion) { - use leptos_reactive::*; - let runtime = create_runtime(); - - c.bench_function("leptos_fan_out", |b| { - b.iter(|| { - create_scope(runtime, |cx| { - let sig = create_rw_signal(cx, 0); - let memos = (0..1000) - .map(|_| create_memo(cx, move |_| sig.get())) - .collect::>(); - assert_eq!(memos.iter().map(|m| m.get()).sum::(), 0); - sig.set(1); - assert_eq!(memos.iter().map(|m| m.get()).sum::(), 1000); - }) - .dispose() - }); - }); - runtime.dispose(); -} - -criterion_group!( - fan_out, - rs_fan_out, - l021_fan_out, - sycamore_fan_out, - leptos_fan_out -); -criterion_main!(fan_out); diff --git a/leptos_reactive/benches/narrow_down.rs b/leptos_reactive/benches/narrow_down.rs deleted file mode 100644 index fbaf4fdc4..000000000 --- a/leptos_reactive/benches/narrow_down.rs +++ /dev/null @@ -1,90 +0,0 @@ -use criterion::{criterion_group, criterion_main, Criterion}; -use std::{cell::Cell, rc::Rc}; - -fn rs_narrow_down(c: &mut Criterion) { - use reactive_signals::{runtimes::ClientRuntime, signal}; - - c.bench_function("rs_narrow_down", |b| { - b.iter(|| { - let cx = ClientRuntime::bench_root_scope(); - let sigs = - Rc::new((0..1000).map(|n| signal!(cx, n)).collect::>()); - let memo = signal!(cx, { - let sigs = Rc::clone(&sigs); - move || sigs.iter().map(|r| r.get()).sum::() - }); - assert_eq!(memo.get(), 499500); - }); - }); -} - -fn l021_narrow_down(c: &mut Criterion) { - use l021::*; - - c.bench_function("l021_narrow_down", |b| { - let runtime = create_runtime(); - b.iter(|| { - create_scope(runtime, |cx| { - let sigs = - (0..1000).map(|n| create_signal(cx, n)).collect::>(); - let reads = sigs.iter().map(|(r, _)| *r).collect::>(); - let memo = create_memo(cx, move |_| { - reads.iter().map(|r| r.get()).sum::() - }); - assert_eq!(memo(), 499500); - }) - .dispose() - }); - runtime.dispose(); - }); -} - -fn sycamore_narrow_down(c: &mut Criterion) { - use sycamore::reactive::*; - - c.bench_function("sycamore_narrow_down", |b| { - b.iter(|| { - let d = create_scope(|cx| { - let sigs = Rc::new( - (0..1000).map(|n| create_signal(cx, n)).collect::>(), - ); - let memo = create_memo(cx, { - let sigs = Rc::clone(&sigs); - move || sigs.iter().map(|r| *r.get()).sum::() - }); - assert_eq!(*memo.get(), 499500); - }); - unsafe { d.dispose() }; - }); - }); -} - -fn leptos_narrow_down(c: &mut Criterion) { - use leptos_reactive::*; - let runtime = create_runtime(); - - c.bench_function("leptos_narrow_down", |b| { - b.iter(|| { - create_scope(runtime, |cx| { - let sigs = - (0..1000).map(|n| create_signal(cx, n)).collect::>(); - let reads = sigs.iter().map(|(r, _)| *r).collect::>(); - let memo = create_memo(cx, move |_| { - reads.iter().map(|r| r.get()).sum::() - }); - assert_eq!(memo(), 499500); - }) - .dispose() - }); - }); - runtime.dispose(); -} - -criterion_group!( - narrow_down, - rs_narrow_down, - l021_narrow_down, - sycamore_narrow_down, - leptos_narrow_down -); -criterion_main!(narrow_down);