-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCEComponent.fs
65 lines (55 loc) · 1.47 KB
/
CEComponent.fs
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
namespace Benchmark.BasicBenchmark
open Microsoft.AspNetCore.Components.Rendering
open Fun.Blazor
type CEComponent() =
inherit FunBlazorComponent()
let mutable count = 0
let increase () = count <- count + 1
member this.Build() =
use builder = new RenderTreeBuilder()
this.BuildRenderTree(builder)
override _.Render() =
let counter =
fragment {
p {
class' "class"
$"Count = {count}"
}
button {
onclick (fun _ -> increase ())
"Increase"
}
}
div {
class' "class"
style' "color: red;"
p {
class' "class"
"p1"
}
p {
class' "class"
"p2"
}
p {
class' "class"
"p3"
}
p {
class' "class"
"p4"
}
p {
class' "class"
"p5"
}
section {
p {
class' "class"
"p6"
}
// Declare a variable help fsharp to have better inline which can save a lot of allocation for delegate
// In this benchmark it can save 40%
counter
}
}