-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_bench.ts
47 lines (40 loc) · 1012 Bytes
/
main_bench.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { attr, html } from "./mod.ts";
Deno.bench("render attr snippet", () => {
attr("placeholder", "fubar");
});
Deno.bench("render html snippet", () => {
html`
<div>Hello, World!</div>
`;
});
Deno.bench("render html snippet with variable", () => {
const message = "World";
html`
<div>Hello, ${message}</div>
`;
});
Deno.bench("render html snippet with variable multiple times", () => {
const template = (message: string) =>
html`
<div>Hello, ${message}</div>
`;
template("world!");
template("world!");
template("world!");
template("world!");
template("world!");
template("world!");
template("world!");
template("world!");
template("world!");
});
Deno.bench("render nested html snippet", () => {
html`
<div>hello, ${html`<p>world!</p>`}</div>
`;
});
Deno.bench("render deeply nested html snippet", () => {
html`
<div>hello, ${html`<p>world! ${html`<p>world! ${html`<p>world!${html`<p>world!${html`<p>world!</p>`}</p>`}</p>`}</p>`}</p>`}</div>
`;
});