Skip to content

Commit

Permalink
add node runnable sample time.js
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Nov 25, 2023
1 parent 895034b commit 9a69ff7
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 5 deletions.
5 changes: 0 additions & 5 deletions .sizesnap.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"dist/index.d.ts": {
"size": "81B",
"brotli": "63B",
"gzip": "84B"
},
"dist/index.js": {
"size": "3.039KB",
"brotli": "955B",
Expand Down
66 changes: 66 additions & 0 deletions bench/time.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// JUST A SAMPLE FILE USING THE UTILITY TO BE USED WITH PERF CHECKS AND GRAPHS

const { renderToString } = require('../dist/index.js')
const fs = require('fs')

let html, reactive, pretty

async function importArrow() {
const mod = await import('@arrow-js/core')
const pmod = await import('pretty-bytes')
html = mod.html
reactive = mod.reactive
pretty = pmod.default
return
}

importArrow().then(_ => {
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(10000).fill(0)).map((x, ind) => ind)
const outerLinks = Array.from(new Array(100).fill(0)).map((x, ind) => ind)
const NavBar = () =>
html`
<header>
<nav>
<ul>
${() =>
outerLinks.map(
_ => 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>
`
}

const out = renderToString(NavBar())
const str = fs.createWriteStream('example.html', 'utf8')
str.write(out)
str.end()
})

0 comments on commit 9a69ff7

Please sign in to comment.