Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F# Feliz.viewengine benchmarks (slower?) #21

Open
jkone27 opened this issue Feb 12, 2024 · 1 comment
Open

F# Feliz.viewengine benchmarks (slower?) #21

jkone27 opened this issue Feb 12, 2024 · 1 comment

Comments

@jkone27
Copy link

jkone27 commented Feb 12, 2024

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 : )

@sporieg
Copy link

sporieg commented Mar 8, 2024

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
        | '<'  -> "&lt;"
        | '>'  -> "&gt;"
        | '\"' -> "&quot;"
        | '\'' -> "&apos;"
        | '&'  -> "&amp;"
        | 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants