Closed SoftCircuits closed 1 year ago
Can you share your code and how you're running it? It may be helpful to share the .notcs file, as well.
@timcassell I'm using it like this.
BenchmarkRunner.Run<Benchmarks>();
public class Benchmarks
{
[Params(@"C:\Users\Jonathan\OneDrive\Desktop\Benchmark.csv", @"C:\Users\Jonathan\OneDrive\Desktop\LargeFile.csv")]
public const string Path = "";
[Benchmark]
public void RunStandardReader() => Run<StandardReader>();
[Benchmark]
public void RunFastStringBuilderReader() => Run<FastStringBuilderReader>();
[Benchmark]
public void RunFastReader() => Run<FastReader>();
private void Run<T>() where T : BaseReader, new()
{
string[]? columns = null;
using T reader = new();
while (reader.ReadRow(ref columns))
{
}
}
}
I have no idea what a .notcs file is. Certainly, I didn't create one.
That's the file that BDN generated to run the benchmarks. It shows in your error log.
C:\Users\Jonathan\source\repos\Temp\CsvReaderProfile\CsvReaderProfile\bin\Release\net7.0\f0435675-95f9-4b00-9933-d0f9b3a28527\f0435675-95f9-4b00-9933-d0f9b3a28527.notcs
@timcassell Well, here it is. Not sure why I seem to be troubleshooting automatically generated code.
// <auto-generated />
// this file must not be importing any namespaces
// we should use full names everywhere to avoid any potential naming conflicts, example: #1007, #778
// the namespace name must be in sync with WindowsDisassembler.BuildArguments
namespace BenchmarkDotNet.Autogenerated
{
public class UniqueProgramName // we need different name than typical "Program" to avoid problems with referencing "Program" types from benchmarked code, #691
{
public static System.Int32 Main(System.String[] args)
{
// this method MUST NOT have any dependencies to BenchmarkDotNet and any other external dlls! (CoreRT is exception from this rule)
// otherwise if LINQPad's shadow copy is enabled, we will not register for AssemblyLoading event
// before .NET Framework tries to load it for this method
#if NETFRAMEWORK
using(new DirtyAssemblyResolveHelper())
#endif
return AfterAssemblyLoadingAttached(args);
}
private static System.Int32 AfterAssemblyLoadingAttached(System.String[] args)
{
BenchmarkDotNet.Engines.IHost host; // this variable name is used by CodeGenerator.GetCoreRtSwitch, do NOT change it
if (BenchmarkDotNet.Engines.AnonymousPipesHost.TryGetFileHandles(args, out System.String writeHandle, out System.String readHandle))
host = new BenchmarkDotNet.Engines.AnonymousPipesHost(writeHandle, readHandle);
else
host = new BenchmarkDotNet.Engines.NoAcknowledgementConsoleHost();
// the first thing to do is to let diagnosers hook in before anything happens
// so all jit-related diagnosers can catch first jit compilation!
BenchmarkDotNet.Engines.HostExtensions.BeforeAnythingElse(host);
try
{
// we are not using Runnable here in any direct way in order to avoid strong dependency Main<=>Runnable
// which could cause the jitting/assembly loading to happen before we do anything
// we have some jitting diagnosers and we want them to catch all the informations!!
// this variable name is used by CodeGenerator.GetCoreRtSwitch, do NOT change it
System.String benchmarkName = System.Linq.Enumerable.FirstOrDefault(System.Linq.Enumerable.Skip(System.Linq.Enumerable.SkipWhile(args, arg => arg != "--benchmarkName"), 1)) ?? "not provided";
System.Int32 id = args.Length > 0
? System.Int32.Parse(args[args.Length - 1]) // this variable name is used by CodeGenerator.GetCoreRtSwitch, do NOT change it
: 0; // used when re-using generated exe without BDN (typically to repro a bug)
if (args.Length == 0)
{
host.WriteLine("You have not specified benchmark id (an integer) so the first benchmark will be executed.");
}
#if NATIVEAOT
#else
System.Type type = typeof(BenchmarkDotNet.Autogenerated.UniqueProgramName).Assembly.GetType($"BenchmarkDotNet.Autogenerated.Runnable_{id}");
type.GetMethod("Run", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static).Invoke(null, new System.Object[] { host, benchmarkName });
#endif
return 0;
}
catch (System.Exception oom) when (oom is System.OutOfMemoryException || oom is System.Reflection.TargetInvocationException reflection && reflection.InnerException is System.OutOfMemoryException)
{
host.WriteLine();
host.WriteLine("OutOfMemoryException!");
host.WriteLine("BenchmarkDotNet continues to run additional iterations until desired accuracy level is achieved. It's possible only if the benchmark method doesn't have any side-effects.");
host.WriteLine("If your benchmark allocates memory and keeps it alive, you are creating a memory leak.");
host.WriteLine("You should redesign your benchmark and remove the side-effects. You can use `OperationsPerInvoke`, `IterationSetup` and `IterationCleanup` to do that.");
host.WriteLine();
host.WriteLine(oom.ToString());
return -1;
}
catch(System.Exception ex)
{
host.WriteLine();
host.WriteLine(ex.ToString());
return -1;
}
finally
{
BenchmarkDotNet.Engines.HostExtensions.AfterAll(host);
host.Dispose();
}
}
}
#if NETFRAMEWORK
internal class DirtyAssemblyResolveHelper : System.IDisposable
{
internal DirtyAssemblyResolveHelper() => System.AppDomain.CurrentDomain.AssemblyResolve += HelpTheFrameworkToResolveTheAssembly;
public void Dispose() => System.AppDomain.CurrentDomain.AssemblyResolve -= HelpTheFrameworkToResolveTheAssembly;
/// <summary>
/// according to https://msdn.microsoft.com/en-us/library/ff527268(v=vs.110).aspx
/// "the handler is invoked whenever the runtime fails to bind to an assembly by name."
/// </summary>
/// <returns>not null when we find it manually, null when can't help</returns>
private System.Reflection.Assembly HelpTheFrameworkToResolveTheAssembly(System.Object sender, System.ResolveEventArgs args)
{
#if SHADOWCOPY // used for LINQPad
const System.String shadowCopyFolderPath = @"";
System.String guessedPath = System.IO.Path.Combine(shadowCopyFolderPath, $"{new System.Reflection.AssemblyName(args.Name).Name}.dll");
return System.IO.File.Exists(guessedPath) ? System.Reflection.Assembly.LoadFrom(guessedPath) : null;
#else
System.Reflection.AssemblyName fullName = new System.Reflection.AssemblyName(args.Name);
System.String simpleName = fullName.Name;
System.String guessedPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, $"{simpleName}.dll");
if (!System.IO.File.Exists(guessedPath))
{
System.Console.WriteLine($"// Wrong assembly binding redirects for {args.Name}.");
return null; // we can't help, and we also don't call Assembly.Load which if fails comes back here, creates endless loop and causes StackOverflow
}
// the file is right there, but has most probably different version and there is no assembly binding redirect or there is a wrong one...
// so we just load it and ignore the version mismatch
// we warn the user about that, in case some Super User want to be aware of that
System.Console.WriteLine($"// Wrong assembly binding redirects for {simpleName}, loading it from disk anyway.");
return System.Reflection.Assembly.LoadFrom(guessedPath);
#endif // SHADOWCOPY
}
}
#endif // NETFRAMEWORK
// the type name must be in sync with WindowsDisassembler.BuildArguments
public unsafe class Runnable_0 : global::CsvReaderProfile.Benchmarks
{
public static void Run(BenchmarkDotNet.Engines.IHost host, System.String benchmarkName)
{
BenchmarkDotNet.Autogenerated.Runnable_0 instance = new BenchmarkDotNet.Autogenerated.Runnable_0(); // do NOT change name "instance" (used in SmartParamameter)
Path = "C:\\Users\\Jonathan\\OneDrive\\Desktop\\Benchmark.csv";
host.WriteLine();
foreach (System.String infoLine in BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.GetCurrent().ToFormattedString())
{
host.WriteLine($"// {infoLine}");
}
BenchmarkDotNet.Jobs.Job job = new BenchmarkDotNet.Jobs.Job(); // use full name to avoid naming conflicts, #778
;
job.Freeze();
host.WriteLine($"// Job: {job.DisplayInfo}");
host.WriteLine();
System.Collections.Generic.IEnumerable<BenchmarkDotNet.Validators.ValidationError> errors = BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.Validate(job);
if (BenchmarkDotNet.Validators.ValidationErrorReporter.ReportIfAny(errors, host))
return;
BenchmarkDotNet.Engines.EngineParameters engineParameters = new BenchmarkDotNet.Engines.EngineParameters()
{
Host = host,
WorkloadActionUnroll = instance.WorkloadActionUnroll,
WorkloadActionNoUnroll = instance.WorkloadActionNoUnroll,
Dummy1Action = instance.Dummy1,
Dummy2Action = instance.Dummy2,
Dummy3Action = instance.Dummy3,
OverheadActionNoUnroll = instance.OverheadActionNoUnroll,
OverheadActionUnroll = instance.OverheadActionUnroll,
GlobalSetupAction = instance.globalSetupAction,
GlobalCleanupAction = instance.globalCleanupAction,
IterationSetupAction = instance.iterationSetupAction,
IterationCleanupAction = instance.iterationCleanupAction,
TargetJob = job,
OperationsPerInvoke = 1,
MeasureExtraStats = false,
BenchmarkName = benchmarkName
};
using (BenchmarkDotNet.Engines.IEngine engine = new BenchmarkDotNet.Engines.EngineFactory().CreateReadyToRun(engineParameters))
{
BenchmarkDotNet.Engines.RunResults results = engine.Run();
host.ReportResults(results); // printing costs memory, do this after runs
instance.__TrickTheJIT__(); // compile the method for disassembler, but without actual run of the benchmark ;)
}
}
public delegate void OverheadDelegate();
public delegate void WorkloadDelegate();
public Runnable_0()
{
globalSetupAction = () => { };
globalCleanupAction = () => { };
iterationSetupAction = () => { };
iterationCleanupAction = () => { };
overheadDelegate = __Overhead;
workloadDelegate = RunStandardReader;
}
private System.Action globalSetupAction;
private System.Action globalCleanupAction;
private System.Action iterationSetupAction;
private System.Action iterationCleanupAction;
private BenchmarkDotNet.Autogenerated.Runnable_0.OverheadDelegate overheadDelegate;
private BenchmarkDotNet.Autogenerated.Runnable_0.WorkloadDelegate workloadDelegate;
// this method is used only for the disassembly diagnoser purposes
// the goal is to get this and the benchmarked method jitted, but without executing the benchmarked method itself
public System.Int32 NotEleven;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __TrickTheJIT__()
{
NotEleven = new System.Random(123).Next(0, 10);
__ForDisassemblyDiagnoser__();
}
private System.Int32 dummyVar;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy1()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy2()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy3()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
private void __Overhead() // __ is to avoid possible name conflict
{
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
}
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __ForDisassemblyDiagnoser__()
{
if (NotEleven == 11)
{
RunStandardReader();
}
}
}
// the type name must be in sync with WindowsDisassembler.BuildArguments
public unsafe class Runnable_1 : global::CsvReaderProfile.Benchmarks
{
public static void Run(BenchmarkDotNet.Engines.IHost host, System.String benchmarkName)
{
BenchmarkDotNet.Autogenerated.Runnable_1 instance = new BenchmarkDotNet.Autogenerated.Runnable_1(); // do NOT change name "instance" (used in SmartParamameter)
Path = "C:\\Users\\Jonathan\\OneDrive\\Desktop\\Benchmark.csv";
host.WriteLine();
foreach (System.String infoLine in BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.GetCurrent().ToFormattedString())
{
host.WriteLine($"// {infoLine}");
}
BenchmarkDotNet.Jobs.Job job = new BenchmarkDotNet.Jobs.Job(); // use full name to avoid naming conflicts, #778
;
job.Freeze();
host.WriteLine($"// Job: {job.DisplayInfo}");
host.WriteLine();
System.Collections.Generic.IEnumerable<BenchmarkDotNet.Validators.ValidationError> errors = BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.Validate(job);
if (BenchmarkDotNet.Validators.ValidationErrorReporter.ReportIfAny(errors, host))
return;
BenchmarkDotNet.Engines.EngineParameters engineParameters = new BenchmarkDotNet.Engines.EngineParameters()
{
Host = host,
WorkloadActionUnroll = instance.WorkloadActionUnroll,
WorkloadActionNoUnroll = instance.WorkloadActionNoUnroll,
Dummy1Action = instance.Dummy1,
Dummy2Action = instance.Dummy2,
Dummy3Action = instance.Dummy3,
OverheadActionNoUnroll = instance.OverheadActionNoUnroll,
OverheadActionUnroll = instance.OverheadActionUnroll,
GlobalSetupAction = instance.globalSetupAction,
GlobalCleanupAction = instance.globalCleanupAction,
IterationSetupAction = instance.iterationSetupAction,
IterationCleanupAction = instance.iterationCleanupAction,
TargetJob = job,
OperationsPerInvoke = 1,
MeasureExtraStats = false,
BenchmarkName = benchmarkName
};
using (BenchmarkDotNet.Engines.IEngine engine = new BenchmarkDotNet.Engines.EngineFactory().CreateReadyToRun(engineParameters))
{
BenchmarkDotNet.Engines.RunResults results = engine.Run();
host.ReportResults(results); // printing costs memory, do this after runs
instance.__TrickTheJIT__(); // compile the method for disassembler, but without actual run of the benchmark ;)
}
}
public delegate void OverheadDelegate();
public delegate void WorkloadDelegate();
public Runnable_1()
{
globalSetupAction = () => { };
globalCleanupAction = () => { };
iterationSetupAction = () => { };
iterationCleanupAction = () => { };
overheadDelegate = __Overhead;
workloadDelegate = RunFastStringBuilderReader;
}
private System.Action globalSetupAction;
private System.Action globalCleanupAction;
private System.Action iterationSetupAction;
private System.Action iterationCleanupAction;
private BenchmarkDotNet.Autogenerated.Runnable_1.OverheadDelegate overheadDelegate;
private BenchmarkDotNet.Autogenerated.Runnable_1.WorkloadDelegate workloadDelegate;
// this method is used only for the disassembly diagnoser purposes
// the goal is to get this and the benchmarked method jitted, but without executing the benchmarked method itself
public System.Int32 NotEleven;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __TrickTheJIT__()
{
NotEleven = new System.Random(123).Next(0, 10);
__ForDisassemblyDiagnoser__();
}
private System.Int32 dummyVar;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy1()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy2()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy3()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
private void __Overhead() // __ is to avoid possible name conflict
{
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
}
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __ForDisassemblyDiagnoser__()
{
if (NotEleven == 11)
{
RunFastStringBuilderReader();
}
}
}
// the type name must be in sync with WindowsDisassembler.BuildArguments
public unsafe class Runnable_2 : global::CsvReaderProfile.Benchmarks
{
public static void Run(BenchmarkDotNet.Engines.IHost host, System.String benchmarkName)
{
BenchmarkDotNet.Autogenerated.Runnable_2 instance = new BenchmarkDotNet.Autogenerated.Runnable_2(); // do NOT change name "instance" (used in SmartParamameter)
Path = "C:\\Users\\Jonathan\\OneDrive\\Desktop\\Benchmark.csv";
host.WriteLine();
foreach (System.String infoLine in BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.GetCurrent().ToFormattedString())
{
host.WriteLine($"// {infoLine}");
}
BenchmarkDotNet.Jobs.Job job = new BenchmarkDotNet.Jobs.Job(); // use full name to avoid naming conflicts, #778
;
job.Freeze();
host.WriteLine($"// Job: {job.DisplayInfo}");
host.WriteLine();
System.Collections.Generic.IEnumerable<BenchmarkDotNet.Validators.ValidationError> errors = BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.Validate(job);
if (BenchmarkDotNet.Validators.ValidationErrorReporter.ReportIfAny(errors, host))
return;
BenchmarkDotNet.Engines.EngineParameters engineParameters = new BenchmarkDotNet.Engines.EngineParameters()
{
Host = host,
WorkloadActionUnroll = instance.WorkloadActionUnroll,
WorkloadActionNoUnroll = instance.WorkloadActionNoUnroll,
Dummy1Action = instance.Dummy1,
Dummy2Action = instance.Dummy2,
Dummy3Action = instance.Dummy3,
OverheadActionNoUnroll = instance.OverheadActionNoUnroll,
OverheadActionUnroll = instance.OverheadActionUnroll,
GlobalSetupAction = instance.globalSetupAction,
GlobalCleanupAction = instance.globalCleanupAction,
IterationSetupAction = instance.iterationSetupAction,
IterationCleanupAction = instance.iterationCleanupAction,
TargetJob = job,
OperationsPerInvoke = 1,
MeasureExtraStats = false,
BenchmarkName = benchmarkName
};
using (BenchmarkDotNet.Engines.IEngine engine = new BenchmarkDotNet.Engines.EngineFactory().CreateReadyToRun(engineParameters))
{
BenchmarkDotNet.Engines.RunResults results = engine.Run();
host.ReportResults(results); // printing costs memory, do this after runs
instance.__TrickTheJIT__(); // compile the method for disassembler, but without actual run of the benchmark ;)
}
}
public delegate void OverheadDelegate();
public delegate void WorkloadDelegate();
public Runnable_2()
{
globalSetupAction = () => { };
globalCleanupAction = () => { };
iterationSetupAction = () => { };
iterationCleanupAction = () => { };
overheadDelegate = __Overhead;
workloadDelegate = RunFastReader;
}
private System.Action globalSetupAction;
private System.Action globalCleanupAction;
private System.Action iterationSetupAction;
private System.Action iterationCleanupAction;
private BenchmarkDotNet.Autogenerated.Runnable_2.OverheadDelegate overheadDelegate;
private BenchmarkDotNet.Autogenerated.Runnable_2.WorkloadDelegate workloadDelegate;
// this method is used only for the disassembly diagnoser purposes
// the goal is to get this and the benchmarked method jitted, but without executing the benchmarked method itself
public System.Int32 NotEleven;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __TrickTheJIT__()
{
NotEleven = new System.Random(123).Next(0, 10);
__ForDisassemblyDiagnoser__();
}
private System.Int32 dummyVar;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy1()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy2()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy3()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
private void __Overhead() // __ is to avoid possible name conflict
{
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
}
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __ForDisassemblyDiagnoser__()
{
if (NotEleven == 11)
{
RunFastReader();
}
}
}
// the type name must be in sync with WindowsDisassembler.BuildArguments
public unsafe class Runnable_3 : global::CsvReaderProfile.Benchmarks
{
public static void Run(BenchmarkDotNet.Engines.IHost host, System.String benchmarkName)
{
BenchmarkDotNet.Autogenerated.Runnable_3 instance = new BenchmarkDotNet.Autogenerated.Runnable_3(); // do NOT change name "instance" (used in SmartParamameter)
Path = "C:\\Users\\Jonathan\\OneDrive\\Desktop\\LargeFile.csv";
host.WriteLine();
foreach (System.String infoLine in BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.GetCurrent().ToFormattedString())
{
host.WriteLine($"// {infoLine}");
}
BenchmarkDotNet.Jobs.Job job = new BenchmarkDotNet.Jobs.Job(); // use full name to avoid naming conflicts, #778
;
job.Freeze();
host.WriteLine($"// Job: {job.DisplayInfo}");
host.WriteLine();
System.Collections.Generic.IEnumerable<BenchmarkDotNet.Validators.ValidationError> errors = BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.Validate(job);
if (BenchmarkDotNet.Validators.ValidationErrorReporter.ReportIfAny(errors, host))
return;
BenchmarkDotNet.Engines.EngineParameters engineParameters = new BenchmarkDotNet.Engines.EngineParameters()
{
Host = host,
WorkloadActionUnroll = instance.WorkloadActionUnroll,
WorkloadActionNoUnroll = instance.WorkloadActionNoUnroll,
Dummy1Action = instance.Dummy1,
Dummy2Action = instance.Dummy2,
Dummy3Action = instance.Dummy3,
OverheadActionNoUnroll = instance.OverheadActionNoUnroll,
OverheadActionUnroll = instance.OverheadActionUnroll,
GlobalSetupAction = instance.globalSetupAction,
GlobalCleanupAction = instance.globalCleanupAction,
IterationSetupAction = instance.iterationSetupAction,
IterationCleanupAction = instance.iterationCleanupAction,
TargetJob = job,
OperationsPerInvoke = 1,
MeasureExtraStats = false,
BenchmarkName = benchmarkName
};
using (BenchmarkDotNet.Engines.IEngine engine = new BenchmarkDotNet.Engines.EngineFactory().CreateReadyToRun(engineParameters))
{
BenchmarkDotNet.Engines.RunResults results = engine.Run();
host.ReportResults(results); // printing costs memory, do this after runs
instance.__TrickTheJIT__(); // compile the method for disassembler, but without actual run of the benchmark ;)
}
}
public delegate void OverheadDelegate();
public delegate void WorkloadDelegate();
public Runnable_3()
{
globalSetupAction = () => { };
globalCleanupAction = () => { };
iterationSetupAction = () => { };
iterationCleanupAction = () => { };
overheadDelegate = __Overhead;
workloadDelegate = RunStandardReader;
}
private System.Action globalSetupAction;
private System.Action globalCleanupAction;
private System.Action iterationSetupAction;
private System.Action iterationCleanupAction;
private BenchmarkDotNet.Autogenerated.Runnable_3.OverheadDelegate overheadDelegate;
private BenchmarkDotNet.Autogenerated.Runnable_3.WorkloadDelegate workloadDelegate;
// this method is used only for the disassembly diagnoser purposes
// the goal is to get this and the benchmarked method jitted, but without executing the benchmarked method itself
public System.Int32 NotEleven;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __TrickTheJIT__()
{
NotEleven = new System.Random(123).Next(0, 10);
__ForDisassemblyDiagnoser__();
}
private System.Int32 dummyVar;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy1()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy2()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy3()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
private void __Overhead() // __ is to avoid possible name conflict
{
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
}
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __ForDisassemblyDiagnoser__()
{
if (NotEleven == 11)
{
RunStandardReader();
}
}
}
// the type name must be in sync with WindowsDisassembler.BuildArguments
public unsafe class Runnable_4 : global::CsvReaderProfile.Benchmarks
{
public static void Run(BenchmarkDotNet.Engines.IHost host, System.String benchmarkName)
{
BenchmarkDotNet.Autogenerated.Runnable_4 instance = new BenchmarkDotNet.Autogenerated.Runnable_4(); // do NOT change name "instance" (used in SmartParamameter)
Path = "C:\\Users\\Jonathan\\OneDrive\\Desktop\\LargeFile.csv";
host.WriteLine();
foreach (System.String infoLine in BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.GetCurrent().ToFormattedString())
{
host.WriteLine($"// {infoLine}");
}
BenchmarkDotNet.Jobs.Job job = new BenchmarkDotNet.Jobs.Job(); // use full name to avoid naming conflicts, #778
;
job.Freeze();
host.WriteLine($"// Job: {job.DisplayInfo}");
host.WriteLine();
System.Collections.Generic.IEnumerable<BenchmarkDotNet.Validators.ValidationError> errors = BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.Validate(job);
if (BenchmarkDotNet.Validators.ValidationErrorReporter.ReportIfAny(errors, host))
return;
BenchmarkDotNet.Engines.EngineParameters engineParameters = new BenchmarkDotNet.Engines.EngineParameters()
{
Host = host,
WorkloadActionUnroll = instance.WorkloadActionUnroll,
WorkloadActionNoUnroll = instance.WorkloadActionNoUnroll,
Dummy1Action = instance.Dummy1,
Dummy2Action = instance.Dummy2,
Dummy3Action = instance.Dummy3,
OverheadActionNoUnroll = instance.OverheadActionNoUnroll,
OverheadActionUnroll = instance.OverheadActionUnroll,
GlobalSetupAction = instance.globalSetupAction,
GlobalCleanupAction = instance.globalCleanupAction,
IterationSetupAction = instance.iterationSetupAction,
IterationCleanupAction = instance.iterationCleanupAction,
TargetJob = job,
OperationsPerInvoke = 1,
MeasureExtraStats = false,
BenchmarkName = benchmarkName
};
using (BenchmarkDotNet.Engines.IEngine engine = new BenchmarkDotNet.Engines.EngineFactory().CreateReadyToRun(engineParameters))
{
BenchmarkDotNet.Engines.RunResults results = engine.Run();
host.ReportResults(results); // printing costs memory, do this after runs
instance.__TrickTheJIT__(); // compile the method for disassembler, but without actual run of the benchmark ;)
}
}
public delegate void OverheadDelegate();
public delegate void WorkloadDelegate();
public Runnable_4()
{
globalSetupAction = () => { };
globalCleanupAction = () => { };
iterationSetupAction = () => { };
iterationCleanupAction = () => { };
overheadDelegate = __Overhead;
workloadDelegate = RunFastStringBuilderReader;
}
private System.Action globalSetupAction;
private System.Action globalCleanupAction;
private System.Action iterationSetupAction;
private System.Action iterationCleanupAction;
private BenchmarkDotNet.Autogenerated.Runnable_4.OverheadDelegate overheadDelegate;
private BenchmarkDotNet.Autogenerated.Runnable_4.WorkloadDelegate workloadDelegate;
// this method is used only for the disassembly diagnoser purposes
// the goal is to get this and the benchmarked method jitted, but without executing the benchmarked method itself
public System.Int32 NotEleven;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __TrickTheJIT__()
{
NotEleven = new System.Random(123).Next(0, 10);
__ForDisassemblyDiagnoser__();
}
private System.Int32 dummyVar;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy1()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy2()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy3()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
private void __Overhead() // __ is to avoid possible name conflict
{
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
}
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __ForDisassemblyDiagnoser__()
{
if (NotEleven == 11)
{
RunFastStringBuilderReader();
}
}
}
// the type name must be in sync with WindowsDisassembler.BuildArguments
public unsafe class Runnable_5 : global::CsvReaderProfile.Benchmarks
{
public static void Run(BenchmarkDotNet.Engines.IHost host, System.String benchmarkName)
{
BenchmarkDotNet.Autogenerated.Runnable_5 instance = new BenchmarkDotNet.Autogenerated.Runnable_5(); // do NOT change name "instance" (used in SmartParamameter)
Path = "C:\\Users\\Jonathan\\OneDrive\\Desktop\\LargeFile.csv";
host.WriteLine();
foreach (System.String infoLine in BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.GetCurrent().ToFormattedString())
{
host.WriteLine($"// {infoLine}");
}
BenchmarkDotNet.Jobs.Job job = new BenchmarkDotNet.Jobs.Job(); // use full name to avoid naming conflicts, #778
;
job.Freeze();
host.WriteLine($"// Job: {job.DisplayInfo}");
host.WriteLine();
System.Collections.Generic.IEnumerable<BenchmarkDotNet.Validators.ValidationError> errors = BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.Validate(job);
if (BenchmarkDotNet.Validators.ValidationErrorReporter.ReportIfAny(errors, host))
return;
BenchmarkDotNet.Engines.EngineParameters engineParameters = new BenchmarkDotNet.Engines.EngineParameters()
{
Host = host,
WorkloadActionUnroll = instance.WorkloadActionUnroll,
WorkloadActionNoUnroll = instance.WorkloadActionNoUnroll,
Dummy1Action = instance.Dummy1,
Dummy2Action = instance.Dummy2,
Dummy3Action = instance.Dummy3,
OverheadActionNoUnroll = instance.OverheadActionNoUnroll,
OverheadActionUnroll = instance.OverheadActionUnroll,
GlobalSetupAction = instance.globalSetupAction,
GlobalCleanupAction = instance.globalCleanupAction,
IterationSetupAction = instance.iterationSetupAction,
IterationCleanupAction = instance.iterationCleanupAction,
TargetJob = job,
OperationsPerInvoke = 1,
MeasureExtraStats = false,
BenchmarkName = benchmarkName
};
using (BenchmarkDotNet.Engines.IEngine engine = new BenchmarkDotNet.Engines.EngineFactory().CreateReadyToRun(engineParameters))
{
BenchmarkDotNet.Engines.RunResults results = engine.Run();
host.ReportResults(results); // printing costs memory, do this after runs
instance.__TrickTheJIT__(); // compile the method for disassembler, but without actual run of the benchmark ;)
}
}
public delegate void OverheadDelegate();
public delegate void WorkloadDelegate();
public Runnable_5()
{
globalSetupAction = () => { };
globalCleanupAction = () => { };
iterationSetupAction = () => { };
iterationCleanupAction = () => { };
overheadDelegate = __Overhead;
workloadDelegate = RunFastReader;
}
private System.Action globalSetupAction;
private System.Action globalCleanupAction;
private System.Action iterationSetupAction;
private System.Action iterationCleanupAction;
private BenchmarkDotNet.Autogenerated.Runnable_5.OverheadDelegate overheadDelegate;
private BenchmarkDotNet.Autogenerated.Runnable_5.WorkloadDelegate workloadDelegate;
// this method is used only for the disassembly diagnoser purposes
// the goal is to get this and the benchmarked method jitted, but without executing the benchmarked method itself
public System.Int32 NotEleven;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __TrickTheJIT__()
{
NotEleven = new System.Random(123).Next(0, 10);
__ForDisassemblyDiagnoser__();
}
private System.Int32 dummyVar;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy1()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy2()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void Dummy3()
{
dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;dummyVar++;
}
private void __Overhead() // __ is to avoid possible name conflict
{
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void OverheadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
overheadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
workloadDelegate();
}
}
#if NETCOREAPP3_0_OR_GREATER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
#endif
private void WorkloadActionNoUnroll(System.Int64 invokeCount)
{
for (System.Int64 i = 0; i < invokeCount; i++)
{
workloadDelegate();
}
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __ForDisassemblyDiagnoser__()
{
if (NotEleven == 11)
{
RunFastReader();
}
}
}
}
Oh, I see the issue. Your Path
is marked as const
, and you are trying to set it via params. Remove the const
modifier and try again.
@AndreyAkinshin Is there a validator that checks for const fields with params?
@timcassell Nice troubleshooting. I made it const because Intellisense was complaining about. Fixed now.
Thanks.
Is there a validator that checks for const fields with params?
We don't have it it (yet). Thank you for your help @timcassell !
The output is so verbose, it's nearly impossible to find the relevant information. Not sure why I seem to be troubleshooting automatically generated code.
You are using a free, open source product that is provided as is. In case you missed it our license is very clear about it:
https://github.com/dotnet/BenchmarkDotNet/blob/master/LICENSE.md
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Next time please read the log output, as it provides a link to our troubleshooting guide which explains how to solve similar issues. If you don't like it, simply stop using it.
Is there a validator that checks for const fields with params?
We don't have it it (yet).
@adamsitnik @timcassell I have created a PR with ParamsValidator
that is looking for constants marked with [Params]
: #2280
@adamsitnik Your disclaimer is a complete non-sequitur to my comment. I have no idea what kind of point you're trying to make there.
I have over a dozen open source packages. I understand how it works. If you're saying you don't want to hear from people using it, please express yourself more clearly.
@SoftCircuits I think you tagged the wrong person. But, tone often doesn't come across in text form, so it seemed like your comment sounded like you didn't want to troubleshoot the issue yourself. As to why you need to troubleshoot auto-generated code, is because it was generated from your own code.
@timcassell I did tag the wrong person. Sorry. It was the disclaimer and accompanying comments that were a non sequitur. I wasn't looking to make a liability claim.
@SoftCircuits thanks for the bug report. I have introduced validation checks for various invalid usages of [Params*]
attributes (see #2280; will be available in v0.13.6
). I believe this issue can be closed now.
If you experience other issues with BenchmarkDotNet, you are welcome to report them (a repro is highly appreciated since it helps to investigate the problem locally).
I'm having serious trouble using this package.
It darkens my screen. And I had to stop the application due to a bug, and now I can't restore my screen.
The output is so verbose, it's nearly impossible to find the relevant information.
And now I get numerous compile errors. Not in my code--my code compiles just fine. But when I run the benchmarks, I get errors.
Is there any way to get the profiler to run?