Skip to content

Commit

Permalink
chore: add in bench for heavy renders
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Nov 19, 2023
1 parent 0c85e6a commit 667dfd3
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 78 deletions.
192 changes: 116 additions & 76 deletions bench.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@
"minTime": 0.05,
"id": 1,
"stats": {
"moe": 2.879228632450289e-10,
"rme": 0.5081758431786834,
"sem": 1.4689942002297394e-10,
"deviation": 1.431798436335639e-9,
"mean": 5.665811689198896e-8,
"variance": 2.050046762293181e-18
"moe": 4.4571210537133215e-10,
"rme": 0.7987258729381004,
"sem": 2.274041353935368e-10,
"deviation": 2.26264257862662e-9,
"mean": 5.5802888133795806e-8,
"variance": 5.11955143861412e-18
},
"times": {
"cycle": 0.05152058548469097,
"elapsed": 5.419,
"period": 5.665811689198896e-8,
"timeStamp": 1698394509214
"cycle": 0.05080830643426855,
"elapsed": 5.525,
"period": 5.5802888133795806e-8,
"timeStamp": 1700385384463
},
"running": false,
"count": 909324,
"cycles": 6,
"hz": 17649721.784900915
"count": 910496,
"cycles": 9,
"hz": 17920219.426678237
}
],
"partials": [
Expand All @@ -67,23 +67,23 @@
"minTime": 0.05,
"id": 2,
"stats": {
"moe": 9.661422433105246e-8,
"rme": 9.213971336508356,
"sem": 4.929297159747575e-8,
"deviation": 3.881332464919646e-7,
"mean": 0.0000010485622409985109,
"variance": 1.5064741703239214e-13
"moe": 6.521885681495138e-8,
"rme": 6.89892458853987,
"sem": 3.3274926946403764e-8,
"deviation": 2.743920769694681e-7,
"mean": 9.45348162281546e-7,
"variance": 7.52910119036185e-14
},
"times": {
"cycle": 0.08367946108064515,
"elapsed": 5.55,
"period": 0.0000010485622409985109,
"timeStamp": 1698394514633
"cycle": 0.07598803063235295,
"elapsed": 5.47,
"period": 9.45348162281546e-7,
"timeStamp": 1700385389989
},
"running": false,
"count": 79804,
"cycles": 9,
"hz": 953686.8303094086
"count": 80381,
"cycles": 8,
"hz": 1057811.3333256552
}
],
"dynamic-partials": [
Expand All @@ -107,23 +107,23 @@
"minTime": 0.05,
"id": 3,
"stats": {
"moe": 3.862446663268995e-8,
"rme": 2.5992455733708555,
"sem": 1.9706360526882627e-8,
"deviation": 1.8168366696903606e-7,
"mean": 0.0000014859875891834049,
"variance": 3.30089548433156e-14
"moe": 5.985988558126182e-9,
"rme": 0.46174229556330887,
"sem": 3.054075794962338e-9,
"deviation": 2.9767448686956854e-8,
"mean": 0.0000012963916486843583,
"variance": 8.861010013306093e-16
},
"times": {
"cycle": 0.059176483764050734,
"elapsed": 5.502,
"period": 0.0000014859875891834049,
"timeStamp": 1698394520184
"cycle": 0.05390655753559299,
"elapsed": 5.436,
"period": 0.0000012963916486843583,
"timeStamp": 1700385395461
},
"running": false,
"count": 39823,
"count": 41582,
"cycles": 5,
"hz": 672953.1304830952
"hz": 771371.8312015114
}
],
"reactive": [
Expand All @@ -147,23 +147,23 @@
"minTime": 0.05,
"id": 4,
"stats": {
"moe": 1.8690875202617585e-8,
"rme": 1.4693377492258417,
"sem": 9.536160817662033e-9,
"deviation": 9.046796495239702e-8,
"mean": 0.0000012720611862361361,
"variance": 8.184452682628135e-15
"moe": 9.793382664937847e-9,
"rme": 0.832972342269395,
"sem": 4.9966238086417585e-9,
"deviation": 4.766475325796617e-8,
"mean": 0.0000011757152270213707,
"variance": 2.2719287031427963e-15
},
"times": {
"cycle": 0.054909793165069054,
"cycle": 0.0542616091574903,
"elapsed": 5.481,
"period": 0.0000012720611862361361,
"timeStamp": 1698394525687
"period": 0.0000011757152270213707,
"timeStamp": 1700385400898
},
"running": false,
"count": 43166,
"cycles": 7,
"hz": 786125.7074896453
"count": 46152,
"cycles": 6,
"hz": 850546.0991038294
}
],
"dynamic-reactive": [
Expand All @@ -187,23 +187,23 @@
"minTime": 0.05,
"id": 5,
"stats": {
"moe": 1.7957427814922795e-8,
"rme": 0.6746270864729684,
"sem": 9.161952966797345e-9,
"deviation": 8.496445648775359e-8,
"mean": 0.0000026618302429578374,
"variance": 7.218958866259374e-15
"moe": 1.759674593141769e-8,
"rme": 0.7147246692025013,
"sem": 8.977931597662087e-9,
"deviation": 8.469763729723892e-8,
"mean": 0.0000024620314212817586,
"variance": 7.173689763734639e-15
},
"times": {
"cycle": 0.06017333447230487,
"elapsed": 5.334,
"period": 0.0000026618302429578374,
"timeStamp": 1698394531169
"cycle": 0.05561236574391236,
"elapsed": 5.443,
"period": 0.0000024620314212817586,
"timeStamp": 1700385406380
},
"running": false,
"count": 22606,
"cycles": 3,
"hz": 375681.3578347489
"count": 22588,
"cycles": 5,
"hz": 406168.6586759278
}
],
"real": [
Expand All @@ -227,23 +227,63 @@
"minTime": 0.05,
"id": 6,
"stats": {
"moe": 8.844987473114782e-8,
"rme": 1.479937366657919,
"sem": 4.512748710772848e-8,
"deviation": 4.42157267151844e-7,
"mean": 0.000005976595815733101,
"variance": 1.9550304889518714e-13
"moe": 2.9667532523642946e-8,
"rme": 0.505865736175033,
"sem": 1.5136496185532115e-8,
"deviation": 1.4830676859255046e-7,
"mean": 0.000005864704881569163,
"variance": 2.1994897610364308e-14
},
"times": {
"cycle": 0.052858585097582865,
"elapsed": 5.574,
"period": 0.000005864704881569163,
"timeStamp": 1700385411824
},
"running": false,
"count": 9013,
"cycles": 5,
"hz": 170511.56370078755
}
],
"goBonkers": [
{
"name": "arrow-render-to-string",
"options": {
"async": false,
"defer": false,
"delay": 0.005,
"initCount": 1,
"maxTime": 5,
"minSamples": 5,
"minTime": 0.05
},
"async": false,
"defer": false,
"delay": 0.005,
"initCount": 1,
"maxTime": 5,
"minSamples": 5,
"minTime": 0.05,
"id": 7,
"stats": {
"moe": 0.07996113881853836,
"rme": 3.17091002204916,
"sem": 0.031101181959758212,
"deviation": 0.07618202619886096,
"mean": 2.5217094860000002,
"variance": 0.005803701115763936
},
"times": {
"cycle": 0.05340686020939099,
"elapsed": 5.321,
"period": 0.000005976595815733101,
"timeStamp": 1698394536504
"cycle": 2.5217094860000002,
"elapsed": 30.584,
"period": 2.5217094860000002,
"timeStamp": 1700385417400
},
"running": false,
"count": 8936,
"cycles": 3,
"hz": 167319.3287335155
"count": 1,
"cycles": 1,
"hz": 0.39655638587703673
}
]
}
Expand Down
41 changes: 41 additions & 0 deletions bench/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ importArrow().then(async _ => {
createSuite('reactive', () => reactiveView())
createSuite('dynamic-reactive', () => dynamicReactiveView())
createSuite('real', () => realWorld())
createSuite('goBonkers', () => goBonkers())
const cpuInfo = await sysInfo.cpu()
const memInfo = await sysInfo.mem()
const base = {
Expand Down Expand Up @@ -133,3 +134,43 @@ function realWorld() {

return Layout(html` ${() => NavBar()} ${() => Counter()} `)
}

function goBonkers() {
const Layout = child => html`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
${child}
</body>
</html>
`

const links = Array.from(new Array(1000).fill(0)).map((x, ind) => ind)
const NavBar = () => html`
<header>
<nav>
<ul>
${() =>
links.map(x => html`<li>${links.map(y => html`<p>${y}</p>`)}</li>`)}
</ul>
</nav>
</header>
`

const state = reactive({
count: 0,
})

const Counter = () => {
return html`
<button @click="${() => (state.count += 1)}">${() => state.count}</button>
`
}

return Layout(html` ${() => NavBar()} ${() => Counter()} `)
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function renderToString(template) {
const isT = 'isT' in template

// FIXME: not a template, throw an error instead,
// move the fault tolerant behavior to another function
// move the fault tolerant behavior to another function
if (!isT) {
return ''
}
Expand Down
Loading

0 comments on commit 667dfd3

Please sign in to comment.