Skip to content

Instantly share code, notes, and snippets.

@neon-sunset
Created July 4, 2023 10:29
Show Gist options
  • Save neon-sunset/a9390d30a068f0489e5e8aa331929759 to your computer and use it in GitHub Desktop.
Save neon-sunset/a9390d30a068f0489e5e8aa331929759 to your computer and use it in GitHub Desktop.
TwitchLib.Client message handling performance of master vs dev + fixes
BenchmarkDotNet=v0.13.5, OS=macOS 14.0 (23A5276g) [Darwin 23.0.0]
Apple M1 Pro, 1 CPU, 8 logical and 8 physical cores
.NET SDK=8.0.100-preview.7.23327.3
  [Host]        : .NET 8.0.0 (8.0.23.32502), Arm64 RyuJIT AdvSIMD
  DefaultJob    : .NET 8.0.0 (8.0.23.32502), Arm64 RyuJIT AdvSIMD
  NativeAOT 8.0 : .NET 8.0.0-preview.7.23325.2, Arm64 NativeAOT AdvSIMD

Underlying IClient.ReceiveMessage -> TwitchClient message handler -> Registered event handler invokation (if any)

Before

Runtime Message Mean Error Gen0 Gen1 Allocated
.NET 8.0 :blub(...) list [66] 326.7 ns 22.33 ns 0.1335 - 840 B
NativeAOT 8.0 :blub(...) list [66] 344.9 ns 25.49 ns 0.1335 - 840 B
.NET 8.0 :jtv(...)ers. [100] 746.7 ns 22.29 ns 0.4196 0.0010 2633 B
NativeAOT 8.0 :jtv(...)ers. [100] 856.8 ns 48.30 ns 0.4168 0.0019 2616 B
.NET 8.0 @bad(...)senE [884] 2,088,881.5 ns 5,092,171.73 ns 1641.8457 1633.3008 25807731 B
NativeAOT 8.0 @bad(...)senE [884] 1,048,723.3 ns 2,785,244.60 ns 1252.9297 1244.1406 12926365 B
.NET 8.0 @bad(...)Guys [382] 1,870.6 ns 69.87 ns 1.4114 0.0076 8858 B
NativeAOT 8.0 @bad(...)Guys [382] 2,203.2 ns 168.62 ns 1.4114 0.0114 8856 B
.NET 8.0 @msg-(...)live. [74] 536.9 ns 18.39 ns 0.3462 - 2177 B
NativeAOT 8.0 @msg-(...)live. [74] 612.4 ns 24.76 ns 0.3462 - 2176 B
.NET 8.0 @msg(...)ces. [110] 395.3 ns 8.41 ns 0.1884 - 1184 B
NativeAOT 8.0 @msg(...)ces. [110] 418.8 ns 15.28 ns 0.1884 - 1184 B

After

Runtime Message Mean Error StdDev Gen0 Gen1 Allocated
.NET 8.0 :blub(...) list [66] 262.5 ns 4.47 ns 5.97 ns 0.0801 - 504 B
NativeAOT 8.0 :blub(...) list [66] 232.1 ns 1.28 ns 1.07 ns 0.0803 - 504 B
.NET 8.0 :jtv(...)ers. [100] 488.1 ns 1.91 ns 1.49 ns 0.2022 - 1272 B
NativeAOT 8.0 :jtv(...)ers. [100] 584.3 ns 3.84 ns 3.59 ns 0.1993 - 1256 B
.NET 8.0 @bad(...)senE [884] 5,250.6 ns 31.21 ns 27.67 ns 2.7618 0.0916 17336 B
NativeAOT 8.0 @bad(...)senE [884] 5,999.9 ns 41.39 ns 34.56 ns 2.7466 0.0916 17240 B
.NET 8.0 @bad(...)Guys [382] 1,161.2 ns 4.37 ns 3.87 ns 0.4177 - 2632 B
NativeAOT 8.0 @bad(...)Guys [382] 1,206.1 ns 4.10 ns 3.83 ns 0.4177 0.0019 2632 B
.NET 8.0 @msg-(...)live. [74] 284.9 ns 1.13 ns 1.06 ns 0.1159 - 728 B
NativeAOT 8.0 @msg-(...)live. [74] 308.6 ns 0.86 ns 0.76 ns 0.1159 - 728 B
.NET 8.0 @msg(...)ces. [110] 344.2 ns 1.31 ns 1.10 ns 0.1273 - 800 B
NativeAOT 8.0 @msg(...)ces. [110] 363.0 ns 1.32 ns 1.23 ns 0.1273 - 800 B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment