Browse Source

Bench: support benchmarking platforms and JIT

benchmark-la
Christoph Ruegg 10 years ago
parent
commit
858eeab485
  1. 6
      src/Benchmark/Benchmark.csproj
  2. 6
      src/Benchmark/Program.cs
  3. 8
      src/Benchmark/Transforms/FFT.cs

6
src/Benchmark/Benchmark.csproj

@ -21,7 +21,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
@ -32,10 +32,10 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />

6
src/Benchmark/Program.cs

@ -1,6 +1,7 @@
using System; using System;
using BenchmarkDotNet.Configs; using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnostics.Windows; using BenchmarkDotNet.Diagnostics.Windows;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running; using BenchmarkDotNet.Running;
using MathNet.Numerics; using MathNet.Numerics;
@ -14,8 +15,9 @@ namespace Benchmark
Console.WriteLine("Linear Algebra: " + Control.LinearAlgebraProvider); Console.WriteLine("Linear Algebra: " + Control.LinearAlgebraProvider);
Console.WriteLine("FFT: " + Control.FourierTransformProvider); Console.WriteLine("FFT: " + Control.FourierTransformProvider);
var config = ManualConfig.Create(DefaultConfig.Instance) var config = ManualConfig.Create(DefaultConfig.Instance);
.With(new MemoryDiagnoser()); //, new InliningDiagnoser()); config.Add(Job.RyuJitX64, Job.LegacyJitX64, Job.LegacyJitX86);
//config.Add(new MemoryDiagnoser());
BenchmarkRunner.Run<Transforms.FFT>(config); BenchmarkRunner.Run<Transforms.FFT>(config);
//BenchmarkRunner.Run<LinearAlgebra.DenseMatrixProduct>(config); //BenchmarkRunner.Run<LinearAlgebra.DenseMatrixProduct>(config);

8
src/Benchmark/Transforms/FFT.cs

@ -14,8 +14,7 @@ namespace Benchmark.Transforms
[Params(32, 64, 128, 1024, 8192, 65536)] [Params(32, 64, 128, 1024, 8192, 65536)]
public int N { get; set; } public int N { get; set; }
[Setup] public FFT()
public void Setup()
{ {
var realSinusoidal = Generate.Sinusoidal(65536, 32, -2.0, 2.0); var realSinusoidal = Generate.Sinusoidal(65536, 32, -2.0, 2.0);
var imagSawtooth = Generate.Sawtooth(65536, 32, -20.0, 20.0); var imagSawtooth = Generate.Sawtooth(65536, 32, -20.0, 20.0);
@ -30,6 +29,11 @@ namespace Benchmark.Transforms
Providers.ForceNativeMKL(); Providers.ForceNativeMKL();
} }
[Setup]
public void Setup()
{
}
[Benchmark(Baseline = true, OperationsPerInvoke = 2)] [Benchmark(Baseline = true, OperationsPerInvoke = 2)]
public void Managed() public void Managed()
{ {

Loading…
Cancel
Save