Skip to content

Commit

Permalink
Automatic Message Batching (#2421)
Browse files Browse the repository at this point in the history
* (○`дノ´)ノ┳┳・゚・┻┻・゚・。

* Recover docs as well.

* Make scheduler synchronous for now.

* Disable Component IDs as they are not useful at the moment.

* Minor fixing, amending messages and apply optimisation on batched messages.
  • Loading branch information
futursolo committed Feb 7, 2022
1 parent 6366925 commit e56ff20
Show file tree
Hide file tree
Showing 18 changed files with 482 additions and 175 deletions.
14 changes: 13 additions & 1 deletion packages/yew-router/tests/basename.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use gloo::timers::future::sleep;
use serde::{Deserialize, Serialize};
use std::time::Duration;
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
use yew::functional::function_component;
use yew::prelude::*;
Expand Down Expand Up @@ -112,19 +114,29 @@ fn root() -> Html {
// - query parameters
// - 404 redirects
#[test]
fn router_works() {
async fn router_works() {
yew::start_app_in_element::<Root>(gloo::utils::document().get_element_by_id("output").unwrap());

sleep(Duration::ZERO).await;

assert_eq!("Home", obtain_result_by_id("result"));

sleep(Duration::ZERO).await;

let initial_length = history_length();

sleep(Duration::ZERO).await;

click("button"); // replacing the current route

sleep(Duration::ZERO).await;
assert_eq!("2", obtain_result_by_id("result-params"));
assert_eq!("bar", obtain_result_by_id("result-query"));
assert_eq!(initial_length, history_length());

click("button"); // pushing a new route

sleep(Duration::ZERO).await;
assert_eq!("3", obtain_result_by_id("result-params"));
assert_eq!("baz", obtain_result_by_id("result-query"));
assert_eq!(initial_length + 1, history_length());
Expand Down
14 changes: 13 additions & 1 deletion packages/yew-router/tests/browser_router.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use gloo::timers::future::sleep;
use serde::{Deserialize, Serialize};
use std::time::Duration;
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
use yew::functional::function_component;
use yew::prelude::*;
Expand Down Expand Up @@ -112,19 +114,29 @@ fn root() -> Html {
// - query parameters
// - 404 redirects
#[test]
fn router_works() {
async fn router_works() {
yew::start_app_in_element::<Root>(gloo::utils::document().get_element_by_id("output").unwrap());

sleep(Duration::ZERO).await;

assert_eq!("Home", obtain_result_by_id("result"));

sleep(Duration::ZERO).await;

let initial_length = history_length();

sleep(Duration::ZERO).await;

click("button"); // replacing the current route

sleep(Duration::ZERO).await;
assert_eq!("2", obtain_result_by_id("result-params"));
assert_eq!("bar", obtain_result_by_id("result-query"));
assert_eq!(initial_length, history_length());

click("button"); // pushing a new route

sleep(Duration::ZERO).await;
assert_eq!("3", obtain_result_by_id("result-params"));
assert_eq!("baz", obtain_result_by_id("result-query"));
assert_eq!(initial_length + 1, history_length());
Expand Down
14 changes: 13 additions & 1 deletion packages/yew-router/tests/hash_router.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use gloo::timers::future::sleep;
use serde::{Deserialize, Serialize};
use std::time::Duration;
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
use yew::functional::function_component;
use yew::prelude::*;
Expand Down Expand Up @@ -112,19 +114,29 @@ fn root() -> Html {
// - query parameters
// - 404 redirects
#[test]
fn router_works() {
async fn router_works() {
yew::start_app_in_element::<Root>(gloo::utils::document().get_element_by_id("output").unwrap());

sleep(Duration::ZERO).await;

assert_eq!("Home", obtain_result_by_id("result"));

sleep(Duration::ZERO).await;

let initial_length = history_length();

sleep(Duration::ZERO).await;

click("button"); // replacing the current route

sleep(Duration::ZERO).await;
assert_eq!("2", obtain_result_by_id("result-params"));
assert_eq!("bar", obtain_result_by_id("result-query"));
assert_eq!(initial_length, history_length());

click("button"); // pushing a new route

sleep(Duration::ZERO).await;
assert_eq!("3", obtain_result_by_id("result-params"));
assert_eq!("baz", obtain_result_by_id("result-query"));
assert_eq!(initial_length + 1, history_length());
Expand Down

1 comment on commit e56ff20

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yew master branch benchmarks (Lower is better)

Benchmark suite Current: e56ff20 Previous: 6366925 Ratio
yew-struct-keyed 01_run1k 159.1725 213.4295 0.75
yew-struct-keyed 02_replace1k 158.20800000000003 234.239 0.68
yew-struct-keyed 03_update10th1k_x16 307.443 448.5355 0.69
yew-struct-keyed 04_select1k 57.0735 90.4245 0.63
yew-struct-keyed 05_swap1k 78.3735 99.735 0.79
yew-struct-keyed 06_remove-one-1k 26.058 30.8775 0.84
yew-struct-keyed 07_create10k 1762.678 2698.133 0.65
yew-struct-keyed 08_create1k-after1k_x2 341.5305 557.3240000000001 0.61
yew-struct-keyed 09_clear1k_x8 171.7745 251.2665 0.68
yew-struct-keyed 21_ready-memory 0.9634513854980468 0.9634513854980468 1
yew-struct-keyed 22_run-memory 1.4538192749023438 1.4578094482421875 1.00
yew-struct-keyed 23_update5-memory 1.4654312133789062 1.4615478515625 1.00
yew-struct-keyed 24_run5-memory 1.5057411193847656 1.510845184326172 1.00
yew-struct-keyed 25_run-clear-memory 1.1287879943847656 1.1287879943847656 1
yew-struct-keyed 31_startup-ci 1737.35 1857.71075 0.94
yew-struct-keyed 32_startup-bt 26.851999999999997 31.641999999999992 0.85
yew-struct-keyed 34_startup-totalbytes 367.962890625 367.962890625 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.