SebastianStehle / mjml-net

.NET Fork of MJML library with 10x performance and 100% feature parity
MIT License
156 stars 14 forks source link

Benchmarks #20

Closed SebastianStehle closed 2 years ago

LiamRiddell commented 2 years ago

I ran some performance tests locally using BenchmarkDotNet. Here's the results in Release mode.

Mean : Arithmetic mean of all measurements Error : Half of 99.9% confidence interval StdDev : Standard deviation of all measurements Median : Value separating the higher half of all measurements (50th percentile) 1 us : 1 Microsecond (0.000001 sec)

MJML.NET v1 - Austin

Method Mean Error StdDev
TryParseDocument 37.64 ms 2.538 ms 7.483 ms
ParseDocument 38.77 ms 2.549 ms 7.515 ms
ParseDocumentAsync 38.24 ms 2.157 ms 6.360 ms

MJML.NET v2

Method Mean Error StdDev Median
Render_Template_Amario_Beautified 1,170.1 us 52.85 us 154.18 us 1,103.5 us
Render_Template_Amario_Minified 1,065.5 us 21.23 us 54.03 us 1,053.5 us
Render_Template_ManyHeroes_Beautified 780.1 us 8.21 us 7.27 us 779.2 us
Render_Template_ManyHeroes_Minified 771.8 us 10.07 us 9.42 us 772.7 us

MJML.NET v2 - Multiple Templates

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19043.1586 (21H1/May2021Update) Intel Core i7-4790 CPU 3.60GHz (Haswell), 1 CPU, 8 logical and 4 physical cores .NET SDK=6.0.101 [Host] : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT DefaultJob : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT

Method Mean Error StdDev Median
Render_Template_Amario_Beautified 972.9 us 9.83 us 8.72 us 970.5 us
Render_Template_Amario_Minified 1,008.0 us 20.09 us 41.49 us 1,001.5 us
Render_Template_Austin_Beautified 332.7 us 6.61 us 17.06 us 327.4 us
Render_Template_Austin_Minified 355.7 us 8.50 us 25.08 us 353.0 us
Render_Template_Sphero_Beautified NA NA NA NA
Render_Template_Sphero_Minified NA NA NA NA

Sphero Failed to Compile. I'm gonna look into this.

SebastianStehle commented 2 years ago

Nice :) ... I hope you are going to push that ;)

I have analyzed that with dotTrace, but the majority of time is spent with the StringBuilder. No idea how to optimize this further.

LiamRiddell commented 2 years ago

Nice :) ... I hope you are going to push that ;)

I have analyzed that with dotTrace, but the majority of time is spent with the StringBuilder. No idea how to optimize this further.

I've created PR now. I'm gonna create new branch for the xml entity issue.