BenchmarkDotNet in LinqPad (AnyCPU) throws an Exception
Recently I posted an issue with BenchmarkDotNet (https://forum.linqpad.net/discussion/1872/benchmarkdotnet-in-linqpad#latest). This turned out to be issue of completely different kind.
But during investigation I tried several LinqPad versions. Beta versions, x86 or AnyCPU I was able to run BenchmarkDotNet in LinqPad, but only in x86 build.
AnyCPU build will throw an FileLoadException.
But during investigation I tried several LinqPad versions. Beta versions, x86 or AnyCPU I was able to run BenchmarkDotNet in LinqPad, but only in x86 build.
AnyCPU build will throw an FileLoadException.
Assembly is still being loaded. (Exception from HRESULT: 0x80131016)
at BenchmarkDotNet.Portability.RuntimeInformation.get_IsFullFramework() at BenchmarkDotNet.Portability.RuntimeInformation.GetCurrentRuntime() at BenchmarkDotNet.Characteristics.Resolver.<>c__DisplayClass1_0`1.<Register>b__0(CharacteristicObject obj) at BenchmarkDotNet.Characteristics.Resolver.Resolve[T](CharacteristicObject obj, Characteristic`1 characteristic) at BenchmarkDotNet.Toolchains.ToolchainExtensions.GetToolchain(Job job) at BenchmarkDotNet.Running.BenchmarkRunnerClean.<>c__DisplayClass12_0.<GetSupportedBenchmarks>b__2(BenchmarkCase benchmark) at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at BenchmarkDotNet.Running.BenchmarkRunnerClean.<>c__DisplayClass12_0.<GetSupportedBenchmarks>b__0(BenchmarkRunInfo info) at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at BenchmarkDotNet.Running.BenchmarkRunnerClean.Run(BenchmarkRunInfo[] benchmarkRunInfos) at BenchmarkDotNet.Running.BenchmarkRunner.RunWithDirtyAssemblyResolveHelper(Type type, IConfig config) at BenchmarkDotNet.Running.BenchmarkRunner.RunWithExceptionHandling(Func`1 run) at BenchmarkDotNet.Running.BenchmarkRunner.Run[T](IConfig config) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()I don't know if this can be called a defect and to which project it actually belongs ...
Comments
It might be a while before I can work further on this because the priority now is on LINQPad 6. The dependency problems are not an issue with .NET Core (and also, because LINQPad 6 has a re-written dependency resolver which looks at reference assemblies as well as runtime assemblies). There are still other unrelated barriers with Benchmark.NET in LINQPad 6 - these will either be remedied or I'll ship a built-in benchmarking tool which will be more ergonomic. I'm thinking of an interface whereby you can highlight any code and press Shift+Ctrl+B to benchmark it.
by
I find your idea of running benchmark with the shortcut great !
I like benchmark dot net's output, which compares times and is also able to compare garbage collections and allocations.
https://www.linqpad.net/LinqReference.aspx
Here's a more elaborate script that allows marking methods with the Benchmark attribute:
http://share.linqpad.net/lorrft.linq
To test it: