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

Avoid state machines #303

Merged
merged 11 commits into from
Apr 14, 2021
Merged

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Apr 8, 2021

Targeted the most obvious choices (often used or simple to change). If was the beast here and I'm sure the coded didn't get too clear by the change. Maybe judge that by the results - it's ugly but so often invoked...

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19042
Intel Core i7-6820HQ CPU 2.70GHz (Skylake), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=5.0.202
  [Host]     : .NET Core 5.0.5 (CoreCLR 5.0.521.16609, CoreFX 5.0.521.16609), X64 RyuJIT
  DefaultJob : .NET Core 5.0.5 (CoreCLR 5.0.521.16609, CoreFX 5.0.521.16609), X64 RyuJIT

Fluid.Benchmarks.TagBenchmarks

Diff Method Mean Error Gen 0 Gen 1 Gen 2 Allocated
Old RawTag_Parse 1,403.9 ns 12.71 ns 0.1125 0.0000 0.0000 472 B
New 1,363.40 ns (-3%) 8.817 ns 0.1125 (0%) 0.0000 0.0000 472 B (0%)
Old RawTag_Render 202.1 ns 0.25 ns 0.0458 0.0000 0.0000 192 B
New 142.58 ns (-29%) 0.419 ns 0.0458 (0%) 0.0000 0.0000 192 B (0%)
Old IfStatement_Ands_Parse 2,933.6 ns 14.34 ns 0.2556 0.0000 0.0000 1080 B
New 2,937.76 ns (0%) 10.568 ns 0.2556 (0%) 0.0000 0.0000 1080 B (0%)
Old IfStatement_Ands_Render 276.9 ns 0.37 ns 0.0134 0.0000 0.0000 56 B
New 159.17 ns (-43%) 0.387 ns 0.0134 (0%) 0.0000 0.0000 56 B (0%)
Old IfStatement_Ors_Parse 2,778.1 ns 18.82 ns 0.2480 0.0000 0.0000 1048 B
New 2,831.34 ns (+2%) 12.927 ns 0.2480 (0%) 0.0000 0.0000 1048 B (0%)
Old IfStatement_Ors_Render 284.9 ns 0.79 ns 0.0134 0.0000 0.0000 56 B
New 163.08 ns (-43%) 0.494 ns 0.0134 (0%) 0.0000 0.0000 56 B (0%)
Old ElseIfStatement_Parse 3,656.2 ns 34.29 ns 0.3128 0.0000 0.0000 1320 B
New 3,719.81 ns (+2%) 20.734 ns 0.3128 (0%) 0.0000 0.0000 1320 B (0%)
Old ElseIfStatement_Render 320.0 ns 1.36 ns 0.0134 0.0000 0.0000 56 B
New 165.62 ns (-48%) 0.825 ns 0.0134 (0%) 0.0000 0.0000 56 B (0%)
Old Assign_Parse 3,322.4 ns 11.51 ns 0.3204 0.0000 0.0000 1352 B
New 3,292.75 ns (-1%) 12.106 ns 0.3204 (0%) 0.0000 0.0000 1352 B (0%)
Old Assign_Render 367.3 ns 0.78 ns 0.0205 0.0000 0.0000 88 B
New 271.46 ns (-26%) 2.938 ns 0.0210 (+2%) 0.0000 0.0000 88 B (0%)
Old Else_Parse 2,098.0 ns 17.45 ns 0.1945 0.0000 0.0000 816 B
New 2,131.72 ns (+2%) 19.065 ns 0.1945 (0%) 0.0000 0.0000 816 B (0%)
Old Else_Render 185.0 ns 0.18 ns 0.0210 0.0000 0.0000 88 B
New 105.97 ns (-43%) 0.224 ns 0.0210 (0%) 0.0000 0.0000 88 B (0%)
Old TextSpan_Parse 307.8 ns 0.97 ns 0.0782 0.0000 0.0000 328 B
New 326.10 ns (+6%) 3.839 ns 0.0782 (0%) 0.0000 0.0000 328 B (0%)
Old TextSpan_Render 103.2 ns 0.34 ns 0.0210 0.0000 0.0000 88 B
New 85.66 ns (-17%) 0.420 ns 0.0210 (0%) 0.0000 0.0000 88 B (0%)

Fluid.Benchmarks.FluidBenchmarks

Diff Method Mean Error Gen 0 Gen 1 Gen 2 Allocated
Old Parse 8.874 μs 0.1658 μs 0.6561 0.0000 0.0000 2.71 KB
New 8.627 μs (-3%) 0.1179 μs 0.6561 (0%) 0.0000 0.0000 2.71 KB (0%)
Old ParseBig 49.396 μs 0.9814 μs 2.9297 0.0610 0.0000 12.13 KB
New 50.067 μs (+1%) 0.3050 μs 2.9297 (0%) 0.0000 (-100%) 0.0000 12.13 KB (0%)
Old Render 638.494 μs 2.5238 μs 22.4609 4.8828 0.0000 95.75 KB
New 599.048 μs (-6%) 2.1111 μs 22.4609 (0%) 4.8828 (0%) 0.0000 95.75 KB (0%)
Old ParseAndRender 643.862 μs 2.1457 μs 23.4375 4.8828 0.0000 98.93 KB
New 611.502 μs (-5%) 3.2349 μs 23.4375 (0%) 4.8828 (0%) 0.0000 98.93 KB (0%)

@lahma lahma force-pushed the reduce-state-machines branch from ef8bfae to 61ae2d3 Compare April 8, 2021 14:54
@lahma lahma marked this pull request as draft April 14, 2021 09:46
@lahma lahma force-pushed the reduce-state-machines branch from 61ae2d3 to 127e4dc Compare April 14, 2021 16:39
@lahma lahma changed the title Avoid state machines in RawStatement Avoid state machines Apr 14, 2021
@lahma lahma marked this pull request as ready for review April 14, 2021 17:35
@lahma lahma force-pushed the reduce-state-machines branch from 1f3d41b to cbf7f88 Compare April 14, 2021 17:43
@sebastienros sebastienros merged commit 458b66b into sebastienros:main Apr 14, 2021
@lahma lahma deleted the reduce-state-machines branch April 14, 2021 20:04
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

Successfully merging this pull request may close these issues.

2 participants