Skip to content

Commit f39afdc

Browse files
authored
Remove benchmarks for now as it does not work at all. (#2495)
1 parent dce04f1 commit f39afdc

4 files changed

Lines changed: 0 additions & 220 deletions

File tree

Makefile.toml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# * lint
66
# * lint-release
77
# * tests
8-
# * benchmarks
98
#
109
# Run `cargo make --list-all-steps` for more details.
1110
#
@@ -40,12 +39,6 @@ dependencies = ["tests-setup"]
4039
env = { CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = ["**/examples/*", "**/packages/changelog"] }
4140
run_task = { name = ["test-flow", "doc-test-flow", "ssr-test", "website-test"], fork = true }
4241

43-
[tasks.benchmarks]
44-
category = "Testing"
45-
description = "Run benchmarks"
46-
env = { CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = ["**/examples/*"] }
47-
run_task = { name = "bench-flow", fork = true }
48-
4942
[tasks.lint-flow]
5043
private = true
5144
workspace = true
@@ -98,16 +91,6 @@ args = ["test", "--doc"]
9891
command = "cargo"
9992
args = ["test", "-p", "website-test"]
10093

101-
[tasks.bench-flow]
102-
private = true
103-
workspace = true
104-
dependencies = ["bench"]
105-
106-
[tasks.bench]
107-
private = true
108-
command = "cargo"
109-
args = ["bench"]
110-
11194
[tasks.generate-change-log]
11295
category = "Maintainer processes"
11396
toolchain = "stable"

packages/yew/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ wasm-bindgen-futures = "0.4"
7070
tokio = { version = "1.15.0", features = ["rt"], optional = true }
7171

7272
[dev-dependencies]
73-
easybench-wasm = "0.2"
7473
wasm-bindgen-test = "0.3"
7574
gloo = { version = "0.6", features = ["futures"] }
7675
wasm-bindgen-futures = "0.4"
@@ -80,7 +79,6 @@ trybuild = "1"
8079
[features]
8180
doc_test = []
8281
wasm_test = []
83-
wasm_bench = []
8482
ssr = ["futures", "html-escape"]
8583
default = []
8684

packages/yew/Makefile.toml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ args = [
2828
"doc_test,wasm_test",
2929
]
3030

31-
[tasks.bench]
32-
extend = "core::wasm-pack-base"
33-
command = "wasm-pack"
34-
args = [
35-
"test",
36-
"--release",
37-
"--firefox",
38-
"--headless",
39-
"--",
40-
"--features",
41-
"wasm_bench",
42-
"bench",
43-
]
44-
4531
[tasks.ssr-test]
4632
command = "cargo"
4733
args = ["test", "ssr_tests", "--features", "ssr"]

packages/yew/src/virtual_dom/mod.rs

Lines changed: 0 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -270,190 +270,3 @@ impl Default for Attributes {
270270
Self::Static(&[])
271271
}
272272
}
273-
274-
#[cfg(all(test, feature = "wasm_bench"))]
275-
mod benchmarks {
276-
use super::*;
277-
use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure};
278-
279-
wasm_bindgen_test_configure!(run_in_browser);
280-
281-
macro_rules! run {
282-
($name:ident => {
283-
$( $old:expr => $new:expr )+
284-
}) => {
285-
// NB: these benchmarks only compare diffing. They do not take into account aspects like
286-
// allocation impact, which is lower for both `Static` and `Dynamic`.
287-
288-
let results = vec![
289-
$(
290-
{
291-
let mut old = $old.clone();
292-
let new = $new.clone();
293-
let el = gloo_utils::document().create_element("div").unwrap();
294-
old.apply(&el);
295-
(
296-
format!("{} -> {}", attr_variant(&old), attr_variant(&new)),
297-
easybench_wasm::bench_env_limit(
298-
2.0,
299-
(NodeCloner(el), new, old),
300-
|(el, mut new, old)| new.apply_diff(&el.0, old),
301-
),
302-
)
303-
},
304-
)+
305-
];
306-
307-
let max_name_len = results.iter().map(|(name, _)| name.len()).max().unwrap_or_default();
308-
wasm_bindgen_test::console_log!(
309-
"{}:{}",
310-
stringify!($name),
311-
results.into_iter().fold(String::new(), |mut acc, (name, res)| {
312-
use std::fmt::Write;
313-
314-
write!(&mut acc, "\n\t\t{:<width$}: ", name, width=max_name_len).unwrap();
315-
316-
if res.ns_per_iter.is_nan() {
317-
acc += "benchmark too slow to produce meaningful results";
318-
} else {
319-
write!(
320-
&mut acc,
321-
"{:>7.4} ns (R²={:.3}, {:>7} iterations in {:>3} samples)",
322-
res.ns_per_iter,
323-
res.goodness_of_fit,
324-
res.iterations,
325-
res.samples,
326-
)
327-
.unwrap();
328-
}
329-
330-
acc
331-
})
332-
);
333-
};
334-
}
335-
336-
#[wasm_bindgen_test]
337-
fn bench_diff_empty() {
338-
let static_ = Attributes::Static(&[]);
339-
let dynamic = Attributes::Dynamic {
340-
keys: &[],
341-
values: Box::new([]),
342-
};
343-
let map = Attributes::IndexMap(Default::default());
344-
345-
run! {
346-
empty => {
347-
static_ => static_
348-
dynamic => dynamic
349-
map => map
350-
static_ => dynamic
351-
static_ => map
352-
dynamic => map
353-
}
354-
}
355-
}
356-
357-
#[wasm_bindgen_test]
358-
fn bench_diff_equal() {
359-
let static_ = Attributes::Static(sample_attrs());
360-
let dynamic = make_dynamic(sample_values());
361-
let map = make_indexed_map(sample_values());
362-
363-
run! {
364-
equal => {
365-
static_ => static_
366-
dynamic => dynamic
367-
map => map
368-
static_ => dynamic
369-
static_ => map
370-
dynamic => map
371-
}
372-
}
373-
}
374-
375-
#[wasm_bindgen_test]
376-
fn bench_diff_change_first() {
377-
let old = sample_values();
378-
let mut new = old.clone();
379-
new[0] = AttrValue::Static("changed");
380-
381-
let dynamic = (make_dynamic(old.clone()), make_dynamic(new.clone()));
382-
let map = (make_indexed_map(old), make_indexed_map(new));
383-
384-
run! {
385-
changed_first => {
386-
dynamic.0 => dynamic.1
387-
map.0 => map.1
388-
dynamic.0 => map.1
389-
}
390-
}
391-
}
392-
393-
fn make_dynamic(values: Vec<AttrValue>) -> Attributes {
394-
Attributes::Dynamic {
395-
keys: sample_keys(),
396-
values: values.into_iter().map(Some).collect(),
397-
}
398-
}
399-
400-
fn make_indexed_map(values: Vec<AttrValue>) -> Attributes {
401-
Attributes::IndexMap(
402-
sample_keys()
403-
.iter()
404-
.copied()
405-
.zip(values.into_iter())
406-
.collect(),
407-
)
408-
}
409-
410-
fn sample_keys() -> &'static [&'static str] {
411-
&[
412-
"oh", "boy", "pipes", "are", "from", "to", "and", "the", "side",
413-
]
414-
}
415-
416-
fn sample_values() -> Vec<AttrValue> {
417-
[
418-
"danny", "the", "the", "calling", "glen", "glen", "down", "mountain", "",
419-
]
420-
.iter()
421-
.map(|v| AttrValue::Static(*v))
422-
.collect()
423-
}
424-
425-
fn sample_attrs() -> &'static [[&'static str; 2]] {
426-
&[
427-
["oh", "danny"],
428-
["boy", "the"],
429-
["pipes", "the"],
430-
["are", "calling"],
431-
["from", "glen"],
432-
["to", "glen"],
433-
["and", "down"],
434-
["the", "mountain"],
435-
["side", ""],
436-
]
437-
}
438-
439-
fn attr_variant(attrs: &Attributes) -> &'static str {
440-
use Attributes::*;
441-
442-
match attrs {
443-
Static(_) => "static",
444-
Dynamic { .. } => "dynamic",
445-
IndexMap(_) => "indexed_map",
446-
}
447-
}
448-
449-
/// Clones the node on [Clone] call
450-
struct NodeCloner(Element);
451-
452-
impl Clone for NodeCloner {
453-
fn clone(&self) -> Self {
454-
use wasm_bindgen::JsCast;
455-
456-
Self(self.0.clone_node().unwrap().dyn_into().unwrap())
457-
}
458-
}
459-
}

0 commit comments

Comments
 (0)