Last active
July 13, 2019 00:57
-
-
Save Nucs/ddac893cc57b727215f124acd9fcda68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Runtime.CompilerServices; | |
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Engines; | |
| using NumSharp.Backends.Unmanaged; | |
| using NumSharp.Memory.Pooling; | |
| using NumSharp.Utilities; | |
| namespace NumSharp.Benchmark.Unmanaged | |
| { | |
| // RAN ON DEBUG BUILD | |
| //| Method | Mean | Error | StdDev | Median | Min | Max | Ratio | RatioSD | | |
| //|-------------------- |---------:|----------:|----------:|---------:|---------:|---------:|------:|--------:| | |
| //| Action_Method | 1.442 ms | 0.0725 ms | 0.9833 ms | 1.044 ms | 1.000 ms | 7.877 ms | 1.22 | 0.86 | | |
| //| Action_Method_stack | 1.161 ms | 0.0427 ms | 0.5789 ms | 1.008 ms | 1.000 ms | 7.042 ms | 0.98 | 0.51 | | |
| //| Action | 1.083 ms | 0.0192 ms | 0.2605 ms | 1.009 ms | 1.000 ms | 5.455 ms | 0.91 | 0.24 | | |
| //| Action_stack | 1.041 ms | 0.0153 ms | 0.2070 ms | 1.002 ms | 1.000 ms | 5.096 ms | 0.88 | 0.21 | | |
| //| Method | 1.223 ms | 0.0250 ms | 0.3395 ms | 1.129 ms | 1.126 ms | 5.226 ms | 1.00 | 0.00 | | |
| // RAN ON RELEASE BUILD | |
| //| Method | Mean | Error | StdDev | Median | Min | Max | Ratio | RatioSD | | |
| //|-------------------- |---------:|----------:|----------:|---------:|---------:|---------:|------:|--------:| | |
| //| Action_Method | 1.145 ms | 0.0392 ms | 0.5317 ms | 1.005 ms | 1.000 ms | 7.531 ms | 0.97 | 0.48 | | |
| //| Action_Method_stack | 1.098 ms | 0.0292 ms | 0.3965 ms | 1.007 ms | 1.000 ms | 6.866 ms | 0.93 | 0.36 | | |
| //| Action | 1.079 ms | 0.0256 ms | 0.3481 ms | 1.002 ms | 1.000 ms | 5.175 ms | 0.92 | 0.33 | | |
| //| Action_stack | 1.046 ms | 0.0187 ms | 0.2538 ms | 1.002 ms | 1.000 ms | 5.601 ms | 0.89 | 0.26 | | |
| //| Method | 1.233 ms | 0.0309 ms | 0.4196 ms | 1.127 ms | 1.099 ms | 5.282 ms | 1.00 | 0.00 | | |
| [SimpleJob(RunStrategy.ColdStart, warmupCount: 5, targetCount: 2000)] | |
| [MinColumn, MaxColumn, MeanColumn, MedianColumn] | |
| [HtmlExporter] | |
| public class NestingCalls | |
| { | |
| private Action action; | |
| private Action action_method; | |
| private int a; | |
| [GlobalSetup] | |
| public void Setup() | |
| { | |
| action = () => a = a + 1 - 1; | |
| action_method = method; | |
| } | |
| [MethodImpl(MethodImplOptions.NoInlining)] | |
| void method() | |
| { | |
| a = a + 1 - 1; | |
| } | |
| [Benchmark] | |
| public void Action_Method() | |
| { | |
| for (int i = 0; i < 500_000; i++) | |
| { | |
| action_method(); | |
| } | |
| } | |
| [Benchmark] | |
| public void Action_Method_stack() | |
| { | |
| var stackvar = action_method; | |
| for (int i = 0; i < 500_000; i++) | |
| { | |
| stackvar(); | |
| } | |
| } | |
| [Benchmark] | |
| public void Action() | |
| { | |
| for (int i = 0; i < 500_000; i++) | |
| { | |
| action(); | |
| } | |
| } | |
| [Benchmark] | |
| public void Action_stack() | |
| { | |
| var stackvar = action; | |
| for (int i = 0; i < 500_000; i++) | |
| { | |
| stackvar(); | |
| } | |
| } | |
| [Benchmark(Baseline = true)] | |
| public void Method() | |
| { | |
| for (int i = 0; i < 500_000; i++) | |
| { | |
| method(); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment