-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add async benchmark and perf iterations (#386)
- Loading branch information
1 parent
45b8e8b
commit 220ad45
Showing
5 changed files
with
96 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'preact-render-to-string': patch | ||
--- | ||
|
||
Add async benchmarks and iterate on perf improvements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { h } from 'preact'; | ||
import { lazy } from 'preact/compat'; | ||
|
||
function Leaf() { | ||
return ( | ||
<div> | ||
<span class="foo" data-testid="stack"> | ||
deep stack | ||
</span> | ||
</div> | ||
); | ||
} | ||
|
||
const lazies = new Array(600) | ||
.fill(600) | ||
.map(() => | ||
lazy(() => | ||
Promise.resolve().then(() => ({ | ||
default: (props) => <div>{props.children}</div> | ||
})) | ||
) | ||
); | ||
function PassThrough(props) { | ||
const Lazy = lazies(props.id); | ||
return <Lazy {...props} />; | ||
} | ||
|
||
function recursive(n, m) { | ||
if (n <= 0) { | ||
return <Leaf />; | ||
} | ||
return <PassThrough id={n * m}>{recursive(n - 1)}</PassThrough>; | ||
} | ||
|
||
const content = []; | ||
for (let i = 0; i < 5; i++) { | ||
content.push(recursive(10, i)); | ||
} | ||
|
||
export default function App() { | ||
return <div>{content}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters