You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A pre-requisite for optimizing our virtual dom implementation is having benchmarks in place to let us know where we're starting from and how much progress we're making.
Here's how I think we can benchmark our virtual_dom_rs::patch function that handles updating the real DOM.
This issue is a pre-requisite for some of the potential future optimizations outlined in #10
A potential approach to benchmarking DOM updates
Create a patch-benchmarks cdylib crate that targets WebAssembly
Has a PatchBenchmark struct where you specify an old and new virtual-dom, similar to our DiffTestCase struct
Each file in this crate has a bench function that returns a -> PatchBenchmark
fnbench() -> PatchBenchmark{PatchBenchmark{first:html!{ <div> </div> },second:html!{ <div id="hello",> </div> },benchmark_backstory:"What was the thinking behind adding this benchmark ..."}}
build.rs script generates an overall benchmark function that
run each of these functions, get the PatchBenchmark
Create the first DOM element and patches it with the second DOM element (and vice versa) a bunch of times and console.log's the average time per patch
We compile our patch-benchmarks crate to WebAssembly
A JS module imports this WASM overall benchmark function and runs it. We bundle this into patch-benchmark-bundle.js
When we have our first benchmarks in place there will probably be more information that we want to have / a cleaner output format that we can iterate towards.. But step one is just having something in place!
The text was updated successfully, but these errors were encountered:
Benchmarking DOM updates
A pre-requisite for optimizing our virtual dom implementation is having benchmarks in place to let us know where we're starting from and how much progress we're making.
Here's how I think we can benchmark our virtual_dom_rs::patch function that handles updating the real DOM.
This issue is a pre-requisite for some of the potential future optimizations outlined in #10
A potential approach to benchmarking DOM updates
Create a
patch-benchmarks
cdylib crate that targets WebAssemblyHas a
PatchBenchmark
struct where you specify an old and new virtual-dom, similar to our DiffTestCase structEach file in this crate has a bench function that returns a
-> PatchBenchmark
build.rs
script generates an overall benchmark function thatPatchBenchmark
first
DOM element and patches it with thesecond
DOM element (and vice versa) a bunch of times andconsole.log
's the average time per patchWe compile our
patch-benchmarks
crate to WebAssemblyA JS module imports this WASM overall benchmark function and runs it. We bundle this into
patch-benchmark-bundle.js
We spawn a headless chrome instance using Google Chrome Puppeteer, and capture the console.log calls, thus capturing all of our benchmark timings.
Write the benchmark timings to stdout!
Potential future improvements
When we have our first benchmarks in place there will probably be more information that we want to have / a cleaner output format that we can iterate towards.. But step one is just having something in place!
The text was updated successfully, but these errors were encountered: