Open jkone27 opened 5 months ago
I ran the recursive html benchmarks locally and the worst performance hit in this case comes from the function getEscapeSequence
If I use the repo as is, the perf report is
Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated |
---|---|---|---|---|---|---|---|
RunFalcoMarkup | 1.166 ms | 0.0225 ms | 0.0309 ms | 166.0156 | 166.0156 | 166.0156 | 2.38 MB |
RunFelizViewEngine | 4.633 ms | 0.0913 ms | 0.2005 ms | 546.8750 | 492.1875 | 164.0625 | 9.01 MB |
If I change the method
let getEscapeSequence c =
match c with
| '<' -> "<"
| '>' -> ">"
| '\"' -> """
| '\'' -> "'"
| '&' -> "&"
| ch -> ch.ToString()
let escape str = String.collect getEscapeSequence str
to
let escape str = System.Net.WebUtility.HtmlEncode str
I get:
Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated |
---|---|---|---|---|---|---|---|
RunFalcoMarkup | 1.094 ms | 0.0214 ms | 0.0189 ms | 166.0156 | 166.0156 | 166.0156 | 2.38 MB |
RunFelizViewEngine | 2.088 ms | 0.0241 ms | 0.0226 ms | 246.0938 | 242.1875 | 164.0625 | 3.6 MB |
There are probably more improvements to find, its still slower but that is the lowest hanging fruit.
https://hamy.xyz/labs/2024-02_fsharp-html-dsl-long-page-benchmarks
https://hamy.xyz/labs/2024-02_fsharp-html-dsl-deeply-nested-benchmarks
seems somehow Feliz is not as performant as Giraffe and Falco, just wonder if there is simple improvements that could be made maybe with help of the community
in general as synthax Feliz.ViewEngine is just better than the other dsls in my view, more expressive and concise (i don't get sir hamy criticism there honestly), or at least is my favourite as empty lists passed around everywhere is not really smt i like or enjoy : )