From 3e6874b99d81d6bf64c147aa97f9b9cead499a94 Mon Sep 17 00:00:00 2001 From: Aiden Bai Date: Sun, 25 Jul 2021 20:17:53 -0700 Subject: [PATCH] fix: benchmarks not using the correct compiler flags --- benchmarks/conditional-render.js | 24 ++++++++++++++++++------ benchmarks/list-render.js | 24 ++++++++++++++++++------ benchmarks/text-interop.js | 19 +++++++++++++------ 3 files changed, 49 insertions(+), 18 deletions(-) diff --git a/benchmarks/conditional-render.js b/benchmarks/conditional-render.js index ebb518ca97..485ca1be74 100644 --- a/benchmarks/conditional-render.js +++ b/benchmarks/conditional-render.js @@ -6,7 +6,8 @@ const conditionalRender = (() => { const benchmark = suite .add('million', { setup() { - document.body.innerHTML = 'conditional-render: Running million benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'conditional-render: Running million benchmarks... (Check console for realtime results)'; const el = Million.createElement(Million.m('div', { id: 'app' })); document.body.appendChild(el); app = el; @@ -16,13 +17,19 @@ const conditionalRender = (() => { const hasChildren = timestamp % 2 === 0; Million.patch( app, - Million.m('div', { id: 'app' }, hasChildren ? [String(timestamp)] : undefined, hasChildren ? 1 : 0), + Million.m( + 'div', + { id: 'app' }, + hasChildren ? [String(timestamp)] : undefined, + hasChildren ? 1 << 1 : 1 << 0, + ), ); }, }) .add('virtual-dom', { setup() { - document.body.innerHTML = 'conditional-render: Running virtual-dom benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'conditional-render: Running virtual-dom benchmarks... (Check console for realtime results)'; const vnode = virtualDom.h('div', { id: 'app', }); @@ -46,7 +53,8 @@ const conditionalRender = (() => { }) .add('vanilla', { setup() { - document.body.innerHTML = 'conditional-render: Running vanilla benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'conditional-render: Running vanilla benchmarks... (Check console for realtime results)'; const el = document.createElement('div'); el.id = 'app'; document.body.appendChild(el); @@ -68,7 +76,8 @@ const conditionalRender = (() => { }) .add('baseline', { setup() { - document.body.innerHTML = 'conditional-render: Running baseline benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'conditional-render: Running baseline benchmarks... (Check console for realtime results)'; const el = document.createElement('div'); el.id = 'app'; document.body.appendChild(el); @@ -83,7 +92,10 @@ const conditionalRender = (() => { output += `${String(target)}
`; }) .on('complete', () => { - const message = `Fastest is ${benchmark.filter('fastest').map('name').join(', ')}`; + const message = `Fastest is ${benchmark + .filter('fastest') + .map('name') + .join(', ')}`; console.log(message); output += `${message}

`; output += `
`; diff --git a/benchmarks/list-render.js b/benchmarks/list-render.js index ba01123768..0fd1a83b4f 100644 --- a/benchmarks/list-render.js +++ b/benchmarks/list-render.js @@ -8,20 +8,27 @@ const listRender = (() => { .add('million', { setup() { children = []; - document.body.innerHTML = 'list-render: Running million benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'list-render: Running million benchmarks... (Check console for realtime results)'; const el = Million.createElement(Million.m('div', { id: 'app' })); document.body.appendChild(el); app = el; }, fn() { children.push(String(Date.now())); - Million.patch(app, Million.m('div', { id: 'app' }, [...children], 1)); + Million.patch( + app, + Million.m('div', { id: 'app' }, [...children], 1 << 1, [ + Million.INSERT(children.length - 1), + ]), + ); }, }) .add('virtual-dom', { setup() { children = []; - document.body.innerHTML = 'list-render: Running virtual-dom benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'list-render: Running virtual-dom benchmarks... (Check console for realtime results)'; const vnode = virtualDom.h('div', { id: 'app', }); @@ -47,7 +54,8 @@ const listRender = (() => { .add('vanilla', { setup() { children = []; - document.body.innerHTML = 'list-render: Running vanilla benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'list-render: Running vanilla benchmarks... (Check console for realtime results)'; const el = document.createElement('div'); el.id = 'app'; document.body.appendChild(el); @@ -72,7 +80,8 @@ const listRender = (() => { .add('baseline', { setup() { children = []; - document.body.innerHTML = 'list-render: Running baseline benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'list-render: Running baseline benchmarks... (Check console for realtime results)'; const el = document.createElement('div'); el.id = 'app'; document.body.appendChild(el); @@ -87,7 +96,10 @@ const listRender = (() => { output += `${String(target)}
`; }) .on('complete', () => { - const message = `Fastest is ${benchmark.filter('fastest').map('name').join(', ')}`; + const message = `Fastest is ${benchmark + .filter('fastest') + .map('name') + .join(', ')}`; console.log(message); output += `${message}

`; output += `
`; diff --git a/benchmarks/text-interop.js b/benchmarks/text-interop.js index 45a73f9c9c..5b1e83dbfd 100644 --- a/benchmarks/text-interop.js +++ b/benchmarks/text-interop.js @@ -6,18 +6,20 @@ const textInterop = (() => { const benchmark = suite .add('million', { setup() { - document.body.innerHTML = 'text-interop: Running million benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'text-interop: Running million benchmarks... (Check console for realtime results)'; const el = Million.createElement(Million.m('div', { id: 'app' })); document.body.appendChild(el); app = el; }, fn() { - Million.patch(app, Million.m('div', { id: 'app' }, [Date.now()], 1)); + Million.patch(app, Million.m('div', { id: 'app' }, [Date.now()], 1 << 1)); }, }) .add('virtual-dom', { setup() { - document.body.innerHTML = 'text-interop: Running virtual-dom benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'text-interop: Running virtual-dom benchmarks... (Check console for realtime results)'; const vnode = virtualDom.h('div', { id: 'app', }); @@ -41,7 +43,8 @@ const textInterop = (() => { }) .add('vanilla', { setup() { - document.body.innerHTML = 'text-interop: Running vanilla benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'text-interop: Running vanilla benchmarks... (Check console for realtime results)'; const el = document.createElement('div'); el.id = 'app'; document.body.appendChild(el); @@ -63,7 +66,8 @@ const textInterop = (() => { }) .add('baseline', { setup() { - document.body.innerHTML = 'text-interop: Running baseline benchmarks... (Check console for realtime results)'; + document.body.innerHTML = + 'text-interop: Running baseline benchmarks... (Check console for realtime results)'; const el = document.createElement('div'); el.id = 'app'; document.body.appendChild(el); @@ -78,7 +82,10 @@ const textInterop = (() => { output += `${String(target)}
`; }) .on('complete', () => { - const message = `Fastest is ${benchmark.filter('fastest').map('name').join(', ')}`; + const message = `Fastest is ${benchmark + .filter('fastest') + .map('name') + .join(', ')}`; console.log(message); output += `${message}

`; output += `
`;