// Note that the parameters will be set as env variables so we cannot use names that conflict
// with the engineering system parameter names.
+//-------------------------- Globals ---------------------------------//
+
+def validTestFolders = [
+ 'Benchstones',
+ 'BenchmarksGame',
+ 'Bytemark',
+ 'Math',
+ 'Span',
+ 'first half',
+ 'last half'
+ ]
+
//--------------------- Windows Functions ----------------------------//
def windowsBuild(String arch, String config, String pgo, boolean isBaseline) {
}
bat "set __TestIntermediateDir=int&&.\\build.cmd -${config} -${arch} -skipbuildpackages ${pgoBuildFlag}"
+ bat "tests\\runtest.cmd ${config} ${arch} GenerateLayoutOnly"
+ bat "rd /s /q bin\\obj"
// Stash build artifacts. Stash tests in an additional stash to be used by Linux test runs
stash name: "nt-${arch}-${pgo}${baselineString}-build-artifacts", includes: 'bin/**'
stash name: "nt-${arch}-${pgo}${baselineString}-test-artifacts", includes: 'bin/tests/**'
}
-def windowsPerf(String arch, String config, String uploadString, String runType, String opt_level, String jit, String pgo, String scenario, boolean isBaseline, boolean isProfileOn) {
+def windowsPerf(String arch, String config, String uploadString, String runType, String opt_level, String jit, String pgo, String scenario, boolean isBaseline, boolean isProfileOn, String testFolder) {
withCredentials([string(credentialsId: 'CoreCLR Perf BenchView Sas', variable: 'BV_UPLOAD_SAS_TOKEN')]) {
checkout scm
String baselineString = ""
baselineString = "-baseline"
}
dir ('.') {
- unstash "nt-${arch}-${pgo}${baselineString}-build-artifacts"
+ unstash "nt-${arch}-${pgo}${baselineString}-test-artifacts"
unstash "benchview-tools"
unstash "metadata"
}
+ String test = ''
+ if (testFolder != 'all') {
+ test = testFolder
+ }
+
String pgoTestFlag = ((pgo == 'nopgo') ? '-nopgo' : '')
// We want to use the baseline metadata for baseline runs. We expect to find the submission metadata in
bat "py \".\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\""
bat ".\\init-tools.cmd"
- bat "run.cmd build -Project=\"tests\\build.proj\" -BuildOS=Windows_NT -BuildType=${config} -BuildArch=${arch} -BatchRestorePackages"
- bat "tests\\runtest.cmd ${config} ${arch} GenerateLayoutOnly"
// We run run-xunit-perf differently for each of the different job types
String runXUnitCommonArgs = "-arch ${arch} -configuration ${config} -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} ${pgoTestFlag} -runtype ${runType} ${testEnv} -optLevel ${opt_level} -jitName ${jit} -outputdir \"%WORKSPACE%\\bin\\sandbox_logs\""
if (scenario == 'perf') {
String runXUnitPerfCommonArgs = "${runXUnitCommonArgs} -stabilityPrefix \"START \"CORECLR_PERF_RUN\" /B /WAIT /HIGH /AFFINITY 0x2\""
- String runXUnitPerflabArgs = "${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${arch}.${config}\\performance\\perflab\\Perflab -library"
+ if (test == 'first half' || testFolder == 'all')
+ {
+ String runXUnitPerflabArgs = "${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${arch}.${config}\\performance\\perflab\\Perflab -library"
- profileArg = isProfileOn ? "default+${profileArg}+gcapi" : profileArg
- bat "tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerflabArgs} -collectionFlags ${profileArg}"
+ profileArg = isProfileOn ? "default+${profileArg}+gcapi" : profileArg
+ bat "tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerflabArgs} -collectionFlags ${profileArg}"
+ }
- String runXUnitCodeQualityArgs = "${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${arch}.${config}\\Jit\\Performance\\CodeQuality"
- bat "tests\\scripts\\run-xunit-perf.cmd ${runXUnitCodeQualityArgs} -collectionFlags ${profileArg}"
+ if (test == 'first half') {
+
+ [
+ 'Burgers',
+ 'Devirtualization',
+ 'FractalPerf',
+ 'Inlining',
+ 'Layout'
+ ].each { benchmark ->
+ String runXUnitCodeQualityArgs = "${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${arch}.${config}\\Jit\\Performance\\CodeQuality\\${benchmark}"
+ bat "tests\\scripts\\run-xunit-perf.cmd ${runXUnitCodeQualityArgs} -collectionFlags ${profileArg}"
+ }
+ }
+ else if (test == 'last half') {
+ [
+ 'Linq',
+ 'Roslyn',
+ 'SciMark',
+ 'Serialization',
+ 'V8'
+ ].each { benchmark ->
+ String runXUnitCodeQualityArgs = "${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${arch}.${config}\\Jit\\Performance\\CodeQuality\\${benchmark}"
+ bat "tests\\scripts\\run-xunit-perf.cmd ${runXUnitCodeQualityArgs} -collectionFlags ${profileArg}"
+ }
+ }
+ else {
+ String runXUnitCodeQualityArgs = "${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${arch}.${config}\\Jit\\Performance\\CodeQuality\\${test}"
+ bat "tests\\scripts\\run-xunit-perf.cmd ${runXUnitCodeQualityArgs} -collectionFlags ${profileArg}"
+ }
}
else if (scenario == 'jitbench') {
String runXUnitPerfCommonArgs = "${runXUnitCommonArgs} -stabilityPrefix \"START \"CORECLR_PERF_RUN\" /B /WAIT /HIGH\" -scenarioTest"
['x64', 'x86'].each { arch ->
['full_opt'].each { opt_level ->
[false].each { isBaseline ->
- String baseline = ""
- if (isBaseline) {
- baseline = " baseline"
- }
- if (isPR() || !isBaseline) {
- innerLoopTests["windows ${arch} ryujit ${opt_level} pgo${baseline} perf"] = {
- simpleNode('windows_server_2016_clr_perf', 180) {
- windowsPerf(arch, config, uploadString, runType, opt_level, 'ryujit', 'pgo', 'perf', isBaseline, true)
+ validTestFolders.each { benchmark ->
+ String baseline = ""
+ if (isBaseline) {
+ baseline = " baseline"
+ }
+ if (isPR() || !isBaseline) {
+ innerLoopTests["windows ${arch} ryujit ${opt_level} pgo ${benchmark}${baseline} perf"] = {
+ simpleNode('windows_server_2016_clr_perf', 180) {
+ windowsPerf(arch, config, uploadString, runType, opt_level, 'ryujit', 'pgo', 'perf', isBaseline, true, benchmark)
+ }
}
}
}
if (!isPR()) {
outerLoopTests["windows ${arch} ryujit full_opt pgo${baseline} jitbench"] = {
simpleNode('windows_server_2016_clr_perf', 180) {
- windowsPerf(arch, config, uploadString, runType, 'full_opt', 'ryujit', 'pgo', 'jitbench', false)
+ windowsPerf(arch, config, uploadString, runType, 'full_opt', 'ryujit', 'pgo', 'jitbench', false, false, '')
}
}
outerLoopTests["windows ${arch} ryujit full_opt pgo${baseline} illink"] = {
simpleNode('Windows_NT', '20170427-elevated') {
- windowsPerf(arch, config, uploadString, runType, 'full_opt', 'ryujit', 'pgo', 'illink', false)
+ windowsPerf(arch, config, uploadString, runType, 'full_opt', 'ryujit', 'pgo', 'illink', false, false, '')
}
}
[true, false].each { isProfileOn ->
outerLoopTests["windows ${arch} ${jit} ${opt_level} ${pgo_enabled} perf"] = {
simpleNode('windows_server_2016_clr_perf', 180) {
- windowsPerf(arch, config, uploadString, runType, opt_level, jit, pgo_enabled, 'perf', false, isProfileOn)
+ windowsPerf(arch, config, uploadString, runType, opt_level, jit, pgo_enabled, 'perf', false, isProfileOn, 'all')
}
}
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// The Adams-Moulton Predictor Corrector Method adapted from Conte and de Boor
-// original source: adams_d.c
-
-using System;
-using System.Runtime.CompilerServices;
-using System.Diagnostics;
-#if XUNIT_PERF
-using Xunit;
-using Microsoft.Xunit.Performance;
-#endif // XUNIT_PERF
-
-#if XUNIT_PERF
-[assembly: OptimizeForBenchmarks]
-#endif // XUNIT_PERF
-
-namespace Benchstone.BenchF
-{
-public static class Adams
-{
-#if DEBUG
- public static int Iterations = 1;
-#else
- public static int Iterations = 200000;
-#endif // DEBUG
-
- static double g_xn, g_yn, g_dn, g_en;
- const double g_xn_base = 0.09999999E+01;
- const double g_yn_base = 0.71828180E+00;
- const double g_dn_base = 0.21287372E-08;
- const double g_en_base = 0.74505806E-08;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static void Bench()
- {
- double[] f = new double[5];
- double xn, yn, dn, en, yxn, h, fnp, ynp, y0, x0, nz;
- int i, k, n, nstep;
-
-#if VERBOSE
- Console.WriteLine(" ADAMS-MOULTON METHOD ");
-#endif // VERBOSE
-
- n = 4;
- h = 1.0 / 32.0;
- nstep = 32;
- y0 = 0.0;
- x0 = 0.0;
- xn = 0.0;
- yn = 0.0;
- dn = 0.0;
- en = 0.0;
- nz = 0;
-
- f[1] = x0 + y0;
-#if VERBOSE
- Console.WriteLine("{0}, {1}, {2}, {3}, {4}", nz, x0, y0, dn, en);
-#endif // VERBOSE
- xn = x0;
- for (i = 2; i <= 4; i++)
- {
- k = i - 1;
- xn = xn + h;
- yn = Soln(xn);
- f[i] = xn + yn;
-#if VERBOSE
- Console.WriteLine("{0}, {1}, {2}, {3}, {4}", k, xn, yn, dn, en);
-#endif // VERBOSE
- }
-
- for (k = 4; k <= nstep; k++)
- {
- ynp = yn + (h / 24) * (55 * f[n] - 59 * f[n - 1] + 37 * f[n - 2] - 9 * f[n - 3]);
- xn = xn + h;
- fnp = xn + ynp;
- yn = yn + (h / 24) * (9 * fnp + 19 * f[n] - 5 * f[n - 1] + f[n - 2]);
- dn = (yn - ynp) / 14;
- f[n - 3] = f[n - 2];
- f[n - 2] = f[n - 1];
- f[n - 1] = f[n];
- f[n] = xn + yn;
- yxn = Soln(xn);
- en = yn - yxn;
-#if VERBOSE
- Console.WriteLine("{0}, {1}, {2}, {3}, {4}", k, xn, yn, dn, en);
-#endif // VERBOSE
- }
-
- // Escape calculated values:
- g_xn = xn;
- g_yn = yn;
- g_dn = dn;
- g_en = en;
- }
-
- private static double Soln(double x)
- {
- return (System.Math.Exp(x) - 1.0 - (x));
- }
-
- [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
- private static void TestBench()
- {
- for (int l = 1; l <= Iterations; l++)
- {
- Bench();
- }
- }
-
-#if XUNIT_PERF
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- TestBench();
- }
- }
- }
-#endif // XUNIT_PERF
-
- [MethodImpl(MethodImplOptions.NoOptimization)]
- public static int Main(string[] argv)
- {
- if (argv.Length > 0)
- {
- Iterations = Int32.Parse(argv[0]);
- }
-
- Stopwatch sw = Stopwatch.StartNew();
- TestBench();
- sw.Stop();
-
- bool result = true;
- // Note: we can't check xn or yn better because of the precision
- // with which original results are given
- result &= System.Math.Abs(g_xn_base - g_xn) <= 1.5e-7;
- result &= System.Math.Abs(g_yn_base - g_yn) <= 1.5e-7;
- result &= System.Math.Abs(g_dn) <= 2.5e-9;
- // Actual error is much bigger than base error;
- // this is likely due to the fact that the original program was written in Fortran
- // and was running on a mainframe with a non-IEEE floating point arithmetic
- // (it's still beyond the published precision of yn)
- result &= System.Math.Abs(g_en) <= 5.5e-8;
- Console.WriteLine(result ? "Passed" : "Failed");
-
- Console.WriteLine(" BASE.....P1 1/4 (ADAMS-MOULTON), XN = {0}", g_xn_base);
- Console.WriteLine(" VERIFY...P1 1/4 (ADAMS-MOULTON), XN = {0}\n", g_xn);
- Console.WriteLine(" BASE.....P1 2/4 (ADAMS-MOULTON), YN = {0}", g_yn_base);
- Console.WriteLine(" VERIFY...P1 2/4 (ADAMS-MOULTON), YN = {0}\n", g_yn);
- Console.WriteLine(" BASE.....P1 3/4 (ADAMS-MOULTON), DN = {0}", g_dn_base);
- Console.WriteLine(" VERIFY...P1 3/4 (ADAMS-MOULTON), DN = {0}\n", g_dn);
- Console.WriteLine(" BASE.....P1 4/4 (ADAMS-MOULTON), EN = {0}", g_en_base);
- Console.WriteLine(" VERIFY...P1 4/4 (ADAMS-MOULTON), EN = {0}\n", g_en);
-
- Console.WriteLine("Test iterations: {0}; Total time: {1} sec", Iterations, sw.Elapsed.TotalSeconds);
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Adams.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class BenchMk2
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 4000000;
-#endif
-
- private static int s_i, s_n;
- private static double s_p, s_a, s_x, s_f, s_e;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- s_p = Math.Acos(-1.0);
- s_a = 0.0;
- s_n = Iterations;
- s_f = s_p / s_n;
- for (s_i = 1; s_i <= s_n; ++s_i)
- {
- s_f = s_p / s_n;
- s_x = s_f * s_i;
- s_e = Math.Abs(Math.Log(Math.Exp(s_x)) / s_x) - Math.Sqrt((Math.Sin(s_x) * Math.Sin(s_x)) + Math.Cos(s_x) * Math.Cos(s_x));
- s_a = s_a + Math.Abs(s_e);
- }
-
- return true;
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="BenchMk2.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class BenchMrk
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 4000000;
-#endif
-
- private static int s_i, s_n;
- private static float s_p, s_a, s_x, s_f, s_e;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- s_p = (float)Math.Acos(-1.0);
- s_a = 0.0F;
- s_n = Iterations;
- s_f = s_p / s_n;
- for (s_i = 1; s_i <= s_n; ++s_i)
- {
- s_f = s_p / s_n;
- s_x = s_f * s_i;
- s_e = (float)(Math.Abs(Math.Log(Math.Exp(s_x)) / s_x) - Math.Sqrt((Math.Sin(s_x) * Math.Sin(s_x)) + Math.Cos(s_x) * Math.Cos(s_x)));
- s_a = s_a + Math.Abs(s_e);
- }
-
- return true;
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="BenchMrk.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// The Bisect algorithm adapted from Conte and de Boor
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class Bisect
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 400000;
-#endif
-
- public static volatile object VolatileObject;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static void Escape(object obj)
- {
- VolatileObject = obj;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- int idbg, iflag;
- double a, b, error, p1, xi;
-
- iflag = 0;
- error = 0.0;
- xi = 0.0;
- idbg = 0;
- for (int i = 1; i <= Iterations; i++)
- {
- for (int j = 1; j <= 10; j++)
- {
- a = 1.0;
- b = 2.0;
- p1 = 0.000001;
- Inner(ref a, ref b, ref p1, out iflag);
- if (iflag > 1)
- {
- goto L999;
- }
-
- xi = (a + b) / 2.0;
- if (a > b)
- {
- error = (a - b) / 2.0;
- }
- else
- {
- error = (b - a) / 2.0;
- }
-
- if (idbg != 0)
- {
- System.Console.WriteLine(" the root is {0:E} plus/minus {1:E}\n", xi, error);
- }
- }
- }
- L999:
- {
- }
-
- // Escape iflag, error, xi so that they appear live
- Escape(iflag);
- Escape(error);
- Escape(xi);
-
- return true;
- }
-
- private static double FF(double x)
- {
- return ((-1.0 - (x * (1.0 - (x * x)))));
- }
-
- private static void Inner(ref double a, ref double b, ref double xtol, out int iflag)
- {
- double fa, error;
- double xm, fm;
-
- iflag = 0;
- fa = FF(a);
- /* check for sign change */
- if (((fa) * FF(b)) < 0.0)
- {
- goto L5;
- }
-
- iflag = 2;
- goto L99;
-
- L5:
- {
- error = System.Math.Abs(b - a);
- }
- L6:
- error = error / 2.0;
- /* check for sufficiently small interval */
- if (error < xtol)
- {
- goto L99;
- }
- xm = (a + b) / 2.0;
- /* check for unreasonable error requirement */
- if (xm + error == xm)
- {
- goto L20;
- }
-
- fm = FF(xm);
- /* change to new interval */
- if (fa * fm < 0.0)
- {
- goto L9;
- }
- a = xm;
- fa = fm;
- goto L6;
- L9:
- b = xm;
- goto L6;
- L20:
- iflag = 1;
- L99:
- {
- }
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Bisect.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class DMath
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 100000;
-#endif
-
- private const double Deg2Rad = 57.29577951;
- private static volatile object s_volatileObject;
-
- private static void Escape(object obj)
- {
- s_volatileObject = obj;
- }
-
- private static double Fact(double n)
- {
- double res;
- res = 1.0;
- while (n > 0.0)
- {
- res *= n;
- n -= 1.0;
- }
-
- return res;
- }
-
- private static double Power(double n, double p)
- {
- double res;
- res = 1.0;
- while (p > 0.0)
- {
- res *= n;
- p -= 1.0;
- }
-
- return res;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench(int loop)
- {
- double[] sines = new double[91];
- double angle, radians, sine, worksine, temp, k;
- double diff;
-
- for (int iter = 1; iter <= loop; iter++)
- {
- for (angle = 0.0; angle <= 90.0; angle += 1.0)
- {
- radians = angle / Deg2Rad;
- k = 0.0;
- worksine = 0.0;
- do
- {
- sine = worksine;
- temp = (2.0 * k) + 1.0;
- worksine += (Power(-1.0, k) / Fact(temp)) * Power(radians, temp);
- k += 1.0;
- diff = Math.Abs(sine - worksine);
- } while (diff > 1E-8);
-
- sines[(int)angle] = worksine;
- }
- }
-
- // Escape sines array so that its elements appear live-out
- Escape(sines);
-
- return true;
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench(Iterations);
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench(Iterations);
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="DMath.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// FFT benchmark adapted from a Fortran routine from the book
-// Digital Signal Analysis, Samuel Stearns, Hayden Book Co.
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class FFT
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 300000;
-#endif
-
- private static readonly int s_points = 16;
- public static volatile object VolatileObject;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static void Escape(object obj)
- {
- VolatileObject = obj;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- double[] fr = new double[17];
- double[] fi = new double[17];
-
- int i;
- double t;
-
- for (int iter = 1; iter <= Iterations; iter++)
- {
- for (i = 1; i <= s_points; ++i)
- {
- t = ((double)0.375) * ((double)(i - 1));
- fr[i] = System.Math.Exp(-t) * System.Math.Sin(t);
- fi[i] = 0.0;
- }
- FastFourierT(fr, fi, s_points);
- }
-
- // Escape the results to live-out.
- Escape(fr);
- Escape(fi);
-
- return true;
- }
-
- private static void FastFourierT(double[] fr, double[] fi, int n)
- {
- int i, j, l, m;
- int istep, mr, nn;
- double a, el, tr, ti, wr, wi;
-
- mr = 0;
- nn = n - 1;
- m = 1;
-
- do
- {
- l = n;
- for (l = l / 2; ((mr + l) > nn); l = l / 2)
- {
- }
- // l <= n/2
- // mr <= (mr % l) + l ==> mr <= (l - 1) + l = 2l - 1
- // ==> mr <= n - 1
- mr = (mr % l) + l;
-
- if (mr > m)
- {
- // Accessing upto m + 1 ==> nn + 1 ==> n - 1 + 1 ==> n
- tr = fr[m + 1];
- // Accessing upto mr + 1 ==> n - 1 + 1 ==> n
- fr[m + 1] = fr[mr + 1];
- fr[mr + 1] = tr;
- ti = fi[m + 1];
- fi[m + 1] = fi[mr + 1];
- fi[mr + 1] = ti;
- }
- ++m;
- } while (m <= nn);
-
- for (l = 1; l < n; l = istep)
- {
- istep = 2 * l;
-
- el = ((double)l);
- m = 1;
- do
- {
- a = ((double)3.1415926535) * (((double)(1 - m)) / el);
- wr = System.Math.Cos(a);
- wi = System.Math.Sin(a);
- i = m;
- do
- {
- // l can have a maximum value of 2^x where 2^x < n and 2^(x+1) = n, since n is even
- // ==> istep <= 2^(x+1) ==> i can only take the value of m and m <= l
- // Therefore, j <= l + l
- // or j <= 2^x + 2^x = 2^(x+1) = n
- // i.e. j <= n
- j = i + l;
-
- // Accessing upto j <= n, i <= n
- tr = wr * fr[j] - wi * fi[j];
- ti = wr * fi[j] + wi * fr[j];
- fr[j] = fr[i] - tr;
- fi[j] = fi[i] - ti;
- fr[i] = fr[i] + tr;
- fi[i] = fi[i] + ti;
- i += istep;
- } while (i <= n);
- ++m;
- } while (m <= l);
- }
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="FFT.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class InProd
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 70;
-#endif
-
- private const int RowSize = 10 * Iterations;
-
- private static int s_seed;
-
- private static T[][] AllocArray<T>(int n1, int n2)
- {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i)
- {
- a[i] = new T[n2];
- }
- return a;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- double[][] rma = AllocArray<double>(RowSize, RowSize);
- double[][] rmb = AllocArray<double>(RowSize, RowSize);
- double[][] rmr = AllocArray<double>(RowSize, RowSize);
-
- double sum;
-
- Inner(rma, rmb, rmr);
-
- for (int i = 1; i < RowSize; i++)
- {
- for (int j = 1; j < RowSize; j++)
- {
- sum = 0;
- for (int k = 1; k < RowSize; k++)
- {
- sum = sum + rma[i][k] * rmb[k][j];
- }
- if (rmr[i][j] != sum)
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
- private static void InitRand()
- {
- s_seed = 7774755;
- }
-
- private static int Rand()
- {
- s_seed = (s_seed * 77 + 13218009) % 3687091;
- return s_seed;
- }
-
- private static void InitMatrix(double[][] m)
- {
- for (int i = 1; i < RowSize; i++)
- {
- for (int j = 1; j < RowSize; j++)
- {
- m[i][j] = (Rand() % 120 - 60) / 3;
- }
- }
- }
-
- private static void InnerProduct(out double result, double[][] a, double[][] b, int row, int col)
- {
- result = 0.0;
- for (int i = 1; i < RowSize; i++)
- {
- result = result + a[row][i] * b[i][col];
- }
- }
-
- private static void Inner(double[][] rma, double[][] rmb, double[][] rmr)
- {
- InitRand();
- InitMatrix(rma);
- InitMatrix(rmb);
- for (int i = 1; i < RowSize; i++)
- {
- for (int j = 1; j < RowSize; j++)
- {
- InnerProduct(out rmr[i][j], rma, rmb, i, j);
- }
- }
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="InProd.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// Solution of linear algebraic equations and matrix inversion.
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class InvMt
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 80;
-#endif
-
- private const int MatSize = Iterations;
-
- private static T[][] AllocArray<T>(int n1, int n2)
- {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i)
- {
- a[i] = new T[n2];
- }
- return a;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- double[][] t = AllocArray<double>(MatSize + 1, (MatSize + 1) * 2);
-
- double det, detinv, ber, p;
- int n, i, j;
-
- n = MatSize;
- for (i = 1; i <= n; i++)
- {
- for (j = 1; j <= n; j++)
- {
- if (i == j)
- {
- t[i][j] = 2.0001;
- t[i][n + 1 + j] = 1.0;
- }
- else
- {
- t[i][j] = 1.0001;
- t[i][n + 1 + j] = 0.0;
- }
- }
- t[i][n + 1] = System.Math.Sqrt((float)i);
- }
-
- Inner(t, out det, ref n);
-
- for (i = 1; i <= n; i++)
- {
- for (j = 1; j <= n; j++)
- {
- p = t[i][j];
- t[i][j] = t[i][n + 1 + j];
- t[i][n + 1 + j] = p;
- }
- }
-
- Inner(t, out detinv, ref n);
-
- ber = 0.0;
- for (i = 1; i <= n; i++)
- {
- ber = ber + System.Math.Abs(System.Math.Sqrt((double)i) - t[i][n + 1]);
- }
-
- return true;
- }
-
- private static void Inner(double[][] t, out double det, ref int n)
- {
- double tik, tkk;
-
- det = 1.0;
- for (int k = 1; k <= n; k++)
- {
- tkk = t[k][k];
- det = det * tkk;
-
- for (int j = 1; j <= (2 * n + 1); j++)
- {
- t[k][j] = t[k][j] / tkk;
- }
-
- for (int i = 1; i <= n; i++)
- {
- if (i != k)
- {
- tik = t[i][k];
- for (int j = 1; j <= (2 * n + 1); j++)
- {
- t[i][j] = t[i][j] - t[k][j] * tik;
- }
- }
- }
- }
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="InvMt.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// C# adaptation of C implementation of Livermore Loops Fortran benchmark.
-
-/* Livermore Loops coded in C Latest File Modification 20 Oct 92,
- * by Tim Peters, Kendall Square Res. Corp. tim@ksr.com, ksr!tim@uunet.uu.net
- * SUBROUTINE KERNEL( TK) replaces the Fortran routine in LFK Test program.
- ************************************************************************
- * *
- * KERNEL executes 24 samples of "C" computation *
- * *
- * TK(1) - total cpu time to execute only the 24 kernels.*
- * TK(2) - total Flops executed by the 24 Kernels *
- * *
- ************************************************************************
- * *
- * L. L. N. L. " C " K E R N E L S: M F L O P S *
- * *
- * These kernels measure " C " numerical computation *
- * rates for a spectrum of cpu-limited computational *
- * structures or benchmarks. Mathematical through-put *
- * is measured in units of millions of floating-point *
- * operations executed per second, called Megaflops/sec. *
- * *
- * Fonzi's Law: There is not now and there never will be a language *
- * in which it is the least bit difficult to write *
- * bad programs. *
- * F.H.MCMAHON 1972 *
- ************************************************************************
- *Originally from Greg Astfalk, AT&T, P.O.Box 900, Princeton, NJ. 08540*
- * by way of Frank McMahon (LLNL). *
- * *
- * REFERENCE *
- * *
- * F.H.McMahon, The Livermore Fortran Kernels: *
- * A Computer Test Of The Numerical Performance Range, *
- * Lawrence Livermore National Laboratory, *
- * Livermore, California, UCRL-53745, December 1986. *
- * *
- * from: National Technical Information Service *
- * U.S. Department of Commerce *
- * 5285 Port Royal Road *
- * Springfield, VA. 22161 *
- * *
- * Changes made to correct many array subscripting problems, *
- * make more readable (added #define's), include the original *
- * FORTRAN versions of the runs as comments, and make more *
- * portable by Kelly O'Hair (LLNL) and Chuck Rasbold (LLNL). *
- * *
- ************************************************************************
- */
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public class LLoops
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 4000;
-#endif
-
- private const double MaxErr = 1.0e-6;
-
- private double[] _x = new double[1002];
- private double[] _y = new double[1002];
- private double[] _z = new double[1002];
- private double[] _u = new double[501];
- private double[][] _px;
- private double[][] _cx;
- private double[][][] _u1;
- private double[][][] _u2;
- private double[][][] _u3;
- private double[][] _b;
- private double[] _bnk1 = new double[6];
- private double[][] _c;
- private double[] _bnk2 = new double[6];
- private double[][] _p;
- private double[] _bnk3 = new double[6];
- private double[][] _h;
- private double[] _bnk4 = new double[6];
- private double[] _bnk5 = new double[6];
- private double[] _ex = new double[68];
- private double[] _rh = new double[68];
- private double[] _dex = new double[68];
- private double[] _vx = new double[151];
- private double[] _xx = new double[151];
- private double[] _grd = new double[151];
- private int[] _e = new int[193];
- private int[] _f = new int[193];
- private int[] _nrops = { 0, 5, 10, 2, 2, 2, 2, 16, 36, 17, 9, 1, 1, 7, 11 };
- private int[] _loops = { 0, 400, 200, 1000, 510, 1000, 1000, 120, 40, 100, 100, 1000, 1000, 128, 150 };
- private double[] _checks = {
- 0, 0.811986948148e+07, 0.356310000000e+03, 0.356310000000e+03, -0.402412007078e+05,
- 0.136579037764e+06, 0.419716278716e+06,
- 0.429449847526e+07, 0.314064400000e+06,
- 0.182709000000e+07, -0.140415250000e+09,
- 0.374895020500e+09, 0.000000000000e+00,
- 0.171449024000e+06, -0.510829560800e+07
- };
-
- public static volatile object VolatileObject;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static void Escape(object obj)
- {
- VolatileObject = obj;
- }
-
- private static T[][] AllocArray<T>(int n1, int n2)
- {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i)
- {
- a[i] = new T[n2];
- }
- return a;
- }
-
- private static T[][][] AllocArray<T>(int n1, int n2, int n3)
- {
- T[][][] a = new T[n1][][];
- for (int i = 0; i < n1; ++i)
- {
- a[i] = new T[n2][];
- for (int j = 0; j < n2; j++)
- {
- a[i][j] = new T[n3];
- }
- }
-
- return a;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private bool Bench()
- {
- _px = AllocArray<double>(16, 101);
- _cx = AllocArray<double>(16, 101);
-
- _u1 = AllocArray<double>(6, 23, 3);
- _u2 = AllocArray<double>(6, 23, 3);
- _u3 = AllocArray<double>(6, 23, 3);
-
- _b = AllocArray<double>(65, 9);
- _c = AllocArray<double>(65, 9);
- _h = AllocArray<double>(65, 9);
-
- _p = AllocArray<double>(5, 513);
-
- for (int i = 0; i < Iterations; i++)
- {
- Main1(i < Iterations - 1 ? 0 : 1);
- }
-
- return true;
- }
-
- private static int Clock()
- {
- return 0;
- }
-
- private void Main1(int output)
- {
- int nt, lw, nl1, nl2;
- int i, i1, i2, ip, ir, ix, j, j1, j2, k, kx, ky, l, m;
- double[] ts = new double[21];
- double[] rt = new double[21];
- double[] rpm = new double[21];
- double[] cksum = new double[21];
- double r, t, a11, a12, a13, sig, a21, a22, a23, a31, a32, a33;
- double b28, b27, b26, b25, b24, b23, b22, c0, flx, rx1;
- double q, s, scale, uu, du1, du2, du3, ar, br, cr, xi, ri;
- int[] mops = new int[20];
-
- for (i = 1; i <= 20; i++)
- {
- cksum[i] = 0.0;
- }
-
- r = 4.86;
- t = 276.0;
- a11 = 0.5;
- a12 = 0.33;
- a13 = 0.25;
- sig = 0.8;
- a21 = 0.20;
- a22 = 0.167;
- a23 = 0.141;
- a31 = 0.125;
- a32 = 0.111;
- a33 = 0.10;
- b28 = 0.1;
- b27 = 0.2;
- b26 = 0.3;
- b25 = 0.4;
- b24 = 0.5;
- b23 = 0.6;
- b22 = 0.7;
- c0 = 0.8;
- flx = 4.689;
- rx1 = 64.0;
-
- /*
- * end of initialization -- begin timing
- */
-
- /* loop 1 hydro excerpt */
-
- Init();
- ts[1] = (double)Clock();
- q = 0.0;
- for (k = 1; k <= 400; k++)
- {
- _x[k] = q + _y[k] * (r * _z[k + 10] + t * _z[k + 11]);
- }
- ts[1] = (double)Clock() - ts[1];
- for (k = 1; k <= 400; k++)
- {
- cksum[1] += (double)k * _x[k];
- }
-
- /* loop 2 mlr, inner product */
-
- Init();
- ts[2] = (double)Clock();
- q = 0.0;
- for (k = 1; k <= 996; k += 5)
- {
- q += _z[k] * _x[k] + _z[k + 1] * _x[k + 1] + _z[k + 2] * _x[k + 2] + _z[k + 3] * _x[k + 3] + _z[k + 4] * _x[k + 4];
- }
- ts[2] = (double)Clock() - ts[2];
- cksum[2] = q;
-
- /* loop 3 inner prod */
-
- Init();
- ts[3] = (double)Clock();
- q = 0.0;
- for (k = 1; k <= 1000; k++)
- {
- q += _z[k] * _x[k];
- }
- ts[3] = (double)Clock() - ts[3];
- cksum[3] = q;
-
- /* loop 4 banded linear equarions */
-
- Init();
- ts[4] = (double)Clock();
- for (l = 7; l <= 107; l += 50)
- {
- lw = l;
- for (j = 30; j <= 870; j += 5)
- {
- _x[l - 1] -= _x[lw++] * _y[j];
- }
- _x[l - 1] = _y[5] * _x[l - 1];
- }
- ts[4] = (double)Clock() - ts[4];
- for (l = 7; l <= 107; l += 50)
- {
- cksum[4] += (double)l * _x[l - 1];
- }
-
- /* loop 5 tri-diagonal elimination, below diagonal */
-
- Init();
- ts[5] = (double)Clock();
- for (i = 2; i <= 998; i += 3)
- {
- _x[i] = _z[i] * (_y[i] - _x[i - 1]);
- _x[i + 1] = _z[i + 1] * (_y[i + 1] - _x[i]);
- _x[i + 2] = _z[i + 2] * (_y[i + 2] - _x[i + 1]);
- }
- ts[5] = (double)Clock() - ts[5];
- for (i = 2; i <= 1000; i++)
- {
- cksum[5] += (double)i * _x[i];
- }
-
- /* loop 6 tri-diagonal elimination, above diagonal */
-
- Init();
- ts[6] = (double)Clock();
- for (j = 3; j <= 999; j += 3)
- {
- i = 1003 - j;
- _x[i] = _x[i] - _z[i] * _x[i + 1];
- _x[i - 1] = _x[i - 1] - _z[i - 1] * _x[i];
- _x[i - 2] = _x[i - 2] - _z[i - 2] * _x[i - 1];
- }
- ts[6] = (double)Clock() - ts[6];
- for (j = 1; j <= 999; j++)
- {
- l = 1001 - j;
- cksum[6] += (double)j * _x[l];
- }
-
- /* loop 7 equation of state excerpt */
-
- Init();
- ts[7] = (double)Clock();
- for (m = 1; m <= 120; m++)
- {
- _x[m] = _u[m] + r * (_z[m] + r * _y[m]) + t * (_u[m + 3] + r * (_u[m + 2] + r * _u[m + 1]) + t * (_u[m + 6] + r * (_u[m + 5] + r * _u[m + 4])));
- }
- ts[7] = (double)Clock() - ts[7];
- for (m = 1; m <= 120; m++)
- {
- cksum[7] += (double)m * _x[m];
- }
-
- /* loop 8 p.d.e. integration */
-
- Init();
- ts[8] = (double)Clock();
- nl1 = 1;
- nl2 = 2;
- for (kx = 2; kx <= 3; kx++)
- {
- for (ky = 2; ky <= 21; ky++)
- {
- du1 = _u1[kx][ky + 1][nl1] - _u1[kx][ky - 1][nl1];
- du2 = _u2[kx][ky + 1][nl1] - _u2[kx][ky - 1][nl1];
- du3 = _u3[kx][ky + 1][nl1] - _u3[kx][ky - 1][nl1];
- _u1[kx][ky][nl2] = _u1[kx][ky][nl1] + a11 * du1 + a12 * du2 + a13 * du3 + sig * (_u1[kx + 1][ky][nl1]
- - 2.0 * _u1[kx][ky][nl1] + _u1[kx - 1][ky][nl1]);
- _u2[kx][ky][nl2] = _u2[kx][ky][nl1] + a21 * du1 + a22 * du2 + a23 * du3 + sig * (_u2[kx + 1][ky][nl1]
- - 2.0 * _u2[kx][ky][nl1] + _u2[kx - 1][ky][nl1]);
- _u3[kx][ky][nl2] = _u3[kx][ky][nl1] + a31 * du1 + a32 * du2 + a33 * du3 + sig * (_u3[kx + 1][ky][nl1]
- - 2.0 * _u3[kx][ky][nl1] + _u3[kx - 1][ky][nl1]);
- }
- }
- ts[8] = (double)Clock() - ts[8];
- for (i = 1; i <= 2; i++)
- {
- for (kx = 2; kx <= 3; kx++)
- {
- for (ky = 2; ky <= 21; ky++)
- {
- cksum[8] += (double)kx * (double)ky * (double)i * (_u1[kx][ky][i] + _u2[kx][ky][i] + _u3[kx][ky][i]);
- }
- }
- }
-
- /* loop 9 integrate predictors */
-
- Init();
- ts[9] = (double)Clock();
- for (i = 1; i <= 100; i++)
- {
- _px[1][i] = b28 * _px[13][i] + b27 * _px[12][i] + b26 * _px[11][i] + b25 * _px[10][i] + b24 * _px[9][i] +
- b23 * _px[8][i] + b22 * _px[7][i] + c0 * (_px[5][i] + _px[6][i]) + _px[3][i];
- }
- ts[9] = (double)Clock() - ts[9];
- for (i = 1; i <= 100; i++)
- {
- cksum[9] += (double)i * _px[1][i];
- }
-
- /* loop 10 difference predictors */
-
- Init();
- ts[10] = (double)Clock();
- for (i = 1; i <= 100; i++)
- {
- ar = _cx[5][i];
- br = ar - _px[5][i];
- _px[5][i] = ar;
- cr = br - _px[6][i];
- _px[6][i] = br;
- ar = cr - _px[7][i];
- _px[7][i] = cr;
- br = ar - _px[8][i];
- _px[8][i] = ar;
- cr = br - _px[9][i];
- _px[9][i] = br;
- ar = cr - _px[10][i];
- _px[10][i] = cr;
- br = ar - _px[11][i];
- _px[11][i] = ar;
- cr = br - _px[12][i];
- _px[12][i] = br;
- _px[14][i] = cr - _px[13][i];
- _px[13][i] = cr;
- }
- ts[10] = (double)Clock() - ts[10];
- for (i = 1; i <= 100; i++)
- {
- for (k = 5; k <= 14; k++)
- {
- cksum[10] += (double)k * (double)i * _px[k][i];
- }
- }
-
- /* loop 11 first sum. */
-
- Init();
- ts[11] = (double)Clock();
- _x[1] = _y[1];
- for (k = 2; k <= 1000; k++)
- {
- _x[k] = _x[k - 1] + _y[k];
- }
- ts[11] = (double)Clock() - ts[11];
- for (k = 1; k <= 1000; k++)
- {
- cksum[11] += (double)k * _x[k];
- }
-
- /* loop 12 first diff. */
-
- Init();
- ts[12] = (double)Clock();
- for (k = 1; k <= 999; k++)
- {
- _x[k] = _y[k + 1] - _y[k];
- }
- ts[12] = (double)Clock() - ts[12];
- for (k = 1; k <= 999; k++)
- {
- cksum[12] += (double)k * _x[k];
- }
-
- /* loop 13 2-d particle pusher */
-
- Init();
- ts[13] = (double)Clock();
- for (ip = 1; ip <= 128; ip++)
- {
- i1 = (int)_p[1][ip];
- j1 = (int)_p[2][ip];
- _p[3][ip] += _b[i1][j1];
- _p[4][ip] += _c[i1][j1];
- _p[1][ip] += _p[3][ip];
- _p[2][ip] += _p[4][ip];
- // Each element of m_p, m_b and m_c is initialized to 1.00025 in Init().
- // From the assignments above,
- // i2 = m_p[1][ip] = m_p[1][ip] + m_p[3][ip] = m_p[1][ip] + m_p[3][ip] + m_b[i1][j1] = 1 + 1 + 1 = 3
- // j2 = m_p[2][ip] = m_p[2][ip] + m_p[4][ip] = m_p[2][ip] + m_p[4][ip] + m_c[i1][j1] = 1 + 1 + 1 = 3
- i2 = (int)_p[1][ip];
- j2 = (int)_p[2][ip];
- // Accessing m_y, m_z upto 35
- _p[1][ip] += _y[i2 + 32];
- _p[2][ip] += _z[j2 + 32];
-
- i2 += _e[i2 + 32];
- j2 += _f[j2 + 32];
- _h[i2][j2] += 1.0;
- }
- ts[13] = (double)Clock() - ts[13];
- for (ip = 1; ip <= 128; ip++)
- {
- cksum[13] += (double)ip * (_p[3][ip] + _p[4][ip] + _p[1][ip] + _p[2][ip]);
- }
- for (k = 1; k <= 64; k++)
- {
- for (ix = 1; ix <= 8; ix++)
- {
- cksum[13] += (double)k * (double)ix * _h[k][ix];
- }
- }
-
- /* loop 14 1-d particle pusher */
-
- Init();
- ts[14] = (double)Clock();
- for (k = 1; k <= 150; k++)
- {
- // m_grd[150] = 13.636
- // Therefore ix <= 13
- ix = (int)_grd[k];
- xi = (double)ix;
- _vx[k] += _ex[ix] + (_xx[k] - xi) * _dex[ix];
- _xx[k] += _vx[k] + flx;
- ir = (int)_xx[k];
- ri = (double)ir;
- rx1 = _xx[k] - ri;
- ir = System.Math.Abs(ir % 64);
- _xx[k] = ri + rx1;
- // ir < 64 since ir = ir % 64
- // So m_rh is accessed upto 64
- _rh[ir] += 1.0 - rx1;
- _rh[ir + 1] += rx1;
- }
- ts[14] = (double)Clock() - ts[14];
- for (k = 1; k <= 150; k++)
- {
- cksum[14] += (double)k * (_vx[k] + _xx[k]);
- }
- for (k = 1; k <= 67; k++)
- {
- cksum[14] += (double)k * _rh[k];
- }
-
- /* time the clock call */
-
- ts[15] = (double)Clock();
- ts[15] = (double)Clock() - ts[15];
-
- /* scale= set to convert time to micro-seconds */
-
- scale = 1.0;
- rt[15] = ts[15] * scale;
-
- nt = 14;
- t = s = uu = 0.0;
- for (k = 1; k <= nt; k++)
- {
- rt[k] = (ts[k] - ts[15]) * scale;
- t += rt[k];
- mops[k] = _nrops[k] * _loops[k];
- s += (double)mops[k];
- rpm[k] = 0.0;
- if (rt[k] != 0.0)
- {
- rpm[k] = (double)mops[k] / rt[k];
- }
- uu += rpm[k];
- }
- uu /= (double)nt;
- s /= t;
-
- // Ensure that the array elements are live-out
- Escape(ts);
- Escape(rt);
- Escape(rpm);
- Escape(cksum);
- Escape(mops);
- }
-
- private void Init()
- {
- int j, k, l;
-
- for (k = 1; k <= 1000; k++)
- {
- _x[k] = 1.11;
- _y[k] = 1.123;
- _z[k] = 0.321;
- }
-
- for (k = 1; k <= 500; k++)
- {
- _u[k] = 0.00025;
- }
-
- for (k = 1; k <= 15; k++)
- {
- for (l = 1; l <= 100; l++)
- {
- _px[k][l] = l;
- _cx[k][l] = l;
- }
- }
-
- for (j = 1; j < 6; j++)
- {
- for (k = 1; k < 23; k++)
- {
- for (l = 1; l < 3; l++)
- {
- _u1[j][k][l] = k;
- _u2[j][k][l] = k + k;
- _u3[j][k][l] = k + k + k;
- }
- }
- }
-
- for (j = 1; j < 65; j++)
- {
- for (k = 1; k < 9; k++)
- {
- _b[j][k] = 1.00025;
- _c[j][k] = 1.00025;
- _h[j][k] = 1.00025;
- }
- }
-
- for (j = 1; j < 6; j++)
- {
- _bnk1[j] = j * 100;
- _bnk2[j] = j * 110;
- _bnk3[j] = j * 120;
- _bnk4[j] = j * 130;
- _bnk5[j] = j * 140;
- }
-
- for (j = 1; j < 5; j++)
- {
- for (k = 1; k < 513; k++)
- {
- _p[j][k] = 1.00025;
- }
- }
-
- for (j = 1; j < 193; j++)
- {
- _e[j] = _f[j] = 1;
- }
-
- for (j = 1; j < 68; j++)
- {
- _ex[j] = _rh[j] = _dex[j] = (double)j;
- }
-
- for (j = 1; j < 151; j++)
- {
- _vx[j] = 0.001;
- _xx[j] = 0.001;
- _grd[j] = (double)(j / 8 + 3);
- }
- }
-
- [Benchmark]
- public static void Test()
- {
- var lloops = new LLoops();
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- lloops.Bench();
- }
- }
- }
-
- private bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- var lloops = new LLoops();
- bool result = lloops.TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="LLoops.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-.NET Core uses third-party libraries or other resources that may be
-distributed under licenses different than the .NET Core software.
-
-In the event that we accidentally failed to list a required notice, please
-bring it to our attention. Post an issue or email us:
-
- dotnet@microsoft.com
-
-The attached notices are provided for information only.
-
-License notice for Livermore Loops coded in C
----------------------------------------------
-
-http://www.netlib.org/benchmark/livermorec
-
-No specific license is given, so attributing and using in "good faith"
-in the same way that it has been offered. We will delete upon request.
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// This program solves the "lorenz" equations using Runge-Kutta 4
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class Lorenz
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 8000000;
-#endif
-
- private static double s_t = 0.0;
- private static double s_x = 5.0;
- private static double s_y = 2.0;
- private static double s_z = 27.0;
-
- private static int s_nsteps = Iterations;
- private static double s_h = -1.0;
- private static int s_printDerivative = -1;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- double k1, k2, k3, k4;
- double l1, l2, l3, l4;
- double m1, m2, m3, m4;
- double hdiv2, hdiv6;
- int i;
-
- if (s_h < 0.0)
- {
- s_h = 20.0 / (double)s_nsteps;
- }
- if (s_printDerivative < 0)
- {
- s_printDerivative = s_nsteps;
- }
-
- hdiv2 = s_h / 2.0;
- hdiv6 = s_h / 6.0;
-
- for (i = 0; i < s_nsteps; ++i)
- {
- double t_arg, x_arg, y_arg, z_arg;
-
- k1 = F(s_t, s_x, s_y, s_z);
- l1 = G(s_t, s_x, s_y, s_z);
- m1 = H(s_t, s_x, s_y, s_z);
-
- t_arg = s_t + hdiv2;
- x_arg = s_x + hdiv2 * k1;
- y_arg = s_y + hdiv2 * l1;
- z_arg = s_z + hdiv2 * m1;
-
- k2 = F(t_arg, x_arg, y_arg, z_arg);
- l2 = G(t_arg, x_arg, y_arg, z_arg);
- m2 = H(t_arg, x_arg, y_arg, z_arg);
-
- x_arg = s_x + hdiv2 * k2;
- y_arg = s_y + hdiv2 * l2;
- z_arg = s_z + hdiv2 * m2;
-
- k3 = F(t_arg, x_arg, y_arg, z_arg);
- l3 = G(t_arg, x_arg, y_arg, z_arg);
- m3 = H(t_arg, x_arg, y_arg, z_arg);
-
- t_arg = s_t + s_h;
- x_arg = s_x + s_h * k3;
- y_arg = s_y + s_h * l3;
- z_arg = s_z + s_h * m3;
-
- k4 = F(t_arg, x_arg, y_arg, z_arg);
- l4 = G(t_arg, x_arg, y_arg, z_arg);
- m4 = H(t_arg, x_arg, y_arg, z_arg);
-
- s_x = s_x + hdiv6 * (k1 + 2.0 * k2 + 2.0 * k3 + k4);
- s_y = s_y + hdiv6 * (l1 + 2.0 * l2 + 2.0 * l3 + l4);
- s_z = s_z + hdiv6 * (m1 + 2.0 * m2 + 2.0 * m3 + m4);
- s_t = t_arg;
- }
-
- return true;
- }
-
- private static double F(double t, double x, double y, double z)
- {
- return (10.0 * (y - x));
- }
-
- private static double G(double t, double x, double y, double z)
- {
- return (x * (28.0 - z) - y);
- }
-
- private static double H(double t, double x, double y, double z)
- {
- return (x * y - (8.0 * z) / 3.0);
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Lorenz.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class MatInv4
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 60;
-#endif
-
- private static float s_det;
-
- private struct X
- {
- public float[] A;
- public X(int size)
- {
- A = new float[size];
- }
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- X a = new X(Iterations * Iterations);
- float[] b = new float[Iterations * Iterations];
- float[] c = new float[Iterations * Iterations];
- float[] d = new float[Iterations * Iterations];
- float[] l1 = new float[Iterations];
- float[] l2 = new float[Iterations];
-
- int i, k, n, nsq;
-
- n = Iterations;
- nsq = n * n;
- for (i = 0; i < n; ++i)
- {
- for (k = 0; k < n; ++k)
- {
- if (i == k)
- {
- a.A[i * n + k] = 40.0F;
- }
- else
- {
- a.A[i * n + k] = 0.0F;
- }
- }
- }
-
- for (i = 0; i < n; ++i)
- {
- for (k = i; k < nsq; k += n)
- {
- b[k] = a.A[k];
- }
- }
-
- /*** second(&t1); ***/
-
- MinV1(b, ref n, out s_det, l1, l2);
-
- if (s_det == 0.0F)
- {
- goto L990;
- }
-
- /*** second(&tx); ***/
-
- MProd(b, a.A, c, ref n);
- for (k = 1; k <= nsq; ++k)
- {
- b[k - 1] = a.A[k - 1];
- }
-
- /*** second(&tx); ***/
-
- MinV2(b, ref n, out s_det, l1, l2);
-
- if (s_det == 0.0F)
- {
- goto L990;
- }
-
- /*** second(&ty); ***/
-
- MProd(b, a.A, d, ref n);
- CompM(c, d, ref n);
-
- /*** second(&t2); ***/
-
- return true;
-
- L990:
- {
- }
-
- return true;
- }
-
- private static void MinV1(float[] a, ref int n, out float d, float[] l, float[] m)
- {
- float biga, hold;
- int i, j, k, ij, ik, ji, jk, nk, ki, kj, kk, iz, jp, jq, jr;
-
- d = 1.0F;
- ji = 0;
- hold = 0.0F;
- nk = -n;
- for (k = 1; k <= n; ++k)
- {
- nk = nk + n;
- l[k - 1] = k;
- m[k - 1] = k;
- kk = nk + k;
- biga = a[kk - 1];
- for (j = k; j <= n; ++j)
- {
- // j <= n, so iz <= n^2 - n
- iz = n * (j - 1);
- for (i = k; i <= n; ++i)
- {
- // iz <= n^2 - n and i <= n, so ij <= n^2
- ij = iz + i;
- if (System.Math.Abs(biga) >= System.Math.Abs(a[ij - 1]))
- {
- continue;
- }
- // accessing up to n^2 - 1
- biga = a[ij - 1];
- l[k - 1] = i;
- m[k - 1] = j;
- }
- }
-
- j = (int)l[k - 1];
-
- if (j <= k)
- {
- goto L35;
- }
-
- // -n < ki <= 0
- ki = k - n;
- for (i = 1; i <= n; ++i)
- {
- // i <= n, ki <= n + n + ... + n (n times) i.e. k <= n * n (when ki = 0 initially)
- ki = ki + n;
- // Accessing upto n^2 -1
- hold = -a[ki - 1];
- // ji <= n^2 - n + n (for ki = 0 initially when k = n and 0 < j <= n)
- // Therefore ji <= n^2
- ji = ki - k + j;
- a[ki - 1] = a[ji - 1];
- a[ji - 1] = hold;
- }
- L35:
- i = (int)m[k - 1];
- if (i <= k)
- {
- goto L45;
- }
-
- // 0 <= jp <= n^2 - n
- jp = n * (i - 1);
- for (j = 1; j <= n; ++j)
- {
- // 0 < nk <= n * (n-1)
- // jk <= n^2 - n + n
- // jk <= n^2
- jk = nk + j;
- // jp <= n^2 - n
- // ji <= n^2 - n + n or ji <= n^2 (since 0 < j <= n)
- ji = jp + j;
- hold = -a[jk - 1];
- a[jk - 1] = a[ji - 1];
- a[ji - 1] = hold;
- }
- L45:
- if (biga != 0.0F)
- {
- goto L48;
- }
- d = 0.0F;
- return;
-
- L48:
- for (i = 1; i <= n; ++i)
- {
- if (i == k)
- {
- break;
- }
- // 0 < nk <= n * (n-1)
- // 0 < ik <= n^2
- ik = nk + i;
- a[ik - 1] = a[ik - 1] / (-biga);
- }
-
- for (i = 1; i <= n; ++i)
- {
- if (i == k)
- {
- continue;
- }
- // 0 < nk <= n * (n-1)
- // 0 < ik <= n^2
- ik = nk + i;
- hold = a[ik - 1];
- // -n < ij <= 0
- ij = i - n;
- for (j = 1; j <= n; ++j)
- {
- // i <= n, ij <= n + n + ... + n (n times) or ij <= n * n
- ij = ij + n;
- if (j == k)
- {
- continue;
- }
- // if i=1, kj = (1 + (n-1) * n) - 1 + n ==> ij = n^2
- // if i=n, kj = (n * n) - n + n ==> ij = n ^2
- // So j <= n^2
- kj = ij - i + k;
- a[ij - 1] = hold * a[kj - 1] + a[ij - 1];
- }
- }
- kj = k - n;
- for (j = 1; j <= n; ++j)
- {
- // k <= n, kj <= n + n + ... + n (n times) or kj <= n * n
- kj = kj + n;
- if (j == k)
- {
- continue;
- }
- // Accessing upto n^2 - 1
- a[kj - 1] = a[kj - 1] / biga;
- }
- d = d * biga;
- a[kk - 1] = 1.0F / biga;
- }
- k = n;
- L100:
- k = k - 1;
- if (k < 1)
- {
- return;
- }
- i = (int)l[k - 1];
- if (i <= k)
- {
- goto L120;
- }
-
- // 0 <= jq <= n^2 - n
- // 0 <= jr <= n^2 - n
- jq = n * (k - 1);
- jr = n * (i - 1);
- for (j = 1; j <= n; ++j)
- {
- // jk <= n^2 - n + n
- // jk <= n^2
- jk = jq + j;
- hold = a[jk - 1];
- // ji <= n^2 - n + n
- // ji <= n^2
- ji = jr + j;
- a[jk - 1] = -a[ji - 1];
- a[ji - 1] = hold;
- }
- L120:
- j = (int)m[k - 1];
- if (j <= k)
- {
- goto L100;
- }
- // 0 <= jr <= n^2 - n
- ki = k - n;
- for (i = 1; i <= n; ++i)
- {
- // ki <= n + n + ... + n (n times) or ki <= n * n
- ki = ki + n;
- hold = a[ki - 1];
- // if i=1, ji = (1 + (n-1) * n) - 1 + n ==> ij = n^2
- // if i=n, ji = (n * n) - n + n ==> ij = n ^2
- // Therefore ji <= n^2
- ji = ki - k + j;
- a[ki - 1] = -a[ji - 1];
- }
- a[ji - 1] = hold;
- goto L100;
- }
-
- private static void MinV2(float[] a, ref int n, out float d, float[] l, float[] m)
- {
- float biga, hold;
- int i, j, k;
-
- d = 1.0F;
- for (k = 1; k <= n; ++k)
- {
- l[k - 1] = k;
- m[k - 1] = k;
- biga = a[(k - 1) * n + (k - 1)];
- for (j = k; j <= n; ++j)
- {
- for (i = k; i <= n; ++i)
- {
- // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
- if (System.Math.Abs(biga) >= System.Math.Abs(a[(i - 1) * n + (j - 1)]))
- {
- continue;
- }
- biga = a[(i - 1) * n + (j - 1)];
- l[k - 1] = i;
- m[k - 1] = j;
- }
- }
- j = (int)l[k - 1];
- if (l[k - 1] <= k)
- {
- goto L200;
- }
- for (i = 1; i <= n; ++i)
- {
- // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
- hold = -a[(k - 1) * n + (i - 1)];
- a[(k - 1) * n + (i - 1)] = a[(j - 1) * n + (i - 1)];
- a[(j - 1) * n + (i - 1)] = hold;
- }
- L200:
- i = (int)m[k - 1];
- if (m[k - 1] <= k)
- {
- goto L250;
- }
- for (j = 1; j <= n; ++j)
- {
- // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
- hold = -a[(j - 1) * n + (k - 1)];
- a[(j - 1) * n + (k - 1)] = a[(j - 1) * n + (i - 1)];
- a[(j - 1) * n + (i - 1)] = hold;
- }
- L250:
- if (biga != 0.0F)
- {
- goto L300;
- }
- d = 0.0F;
- return;
-
- L300:
- for (i = 1; i <= n; ++i)
- {
- if (i != k)
- {
- // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
- a[(i - 1) * n + (k - 1)] = a[(i - 1) * n + (k - 1)] / (-biga);
- }
- }
- for (i = 1; i <= n; ++i)
- {
- if (i == k)
- {
- continue;
- }
- for (j = 1; j <= n; ++j)
- {
- if (j != k)
- {
- // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
- a[(i - 1) * n + (j - 1)] = a[(i - 1) * n + (k - 1)] * a[(k - 1) * n + (j - 1)] + a[(i - 1) * n + (j - 1)];
- }
- }
- }
- for (j = 1; j < n; ++j)
- {
- if (j != k)
- {
- // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
- a[(k - 1) * n + (j - 1)] = a[(k - 1) * n + (j - 1)] / biga;
- }
- }
- d = d * biga;
- a[(k - 1) * n + (k - 1)] = 1.0F / biga;
- }
- k = n;
- L400:
- k = k - 1;
- if (k < 1)
- {
- return;
- }
- i = (int)l[k - 1];
- if (i <= k)
- {
- goto L450;
- }
- for (j = 1; j <= n; ++j)
- {
- // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
- hold = a[(j - 1) * n + (k - 1)];
- a[(j - 1) * n + (k - 1)] = -a[(j - 1) * n + (i - 1)];
- a[(j - 1) * n + (i - 1)] = hold;
- }
- L450:
- j = (int)m[k - 1];
- if (j <= k)
- {
- goto L400;
- }
- for (i = 1; i <= n; ++i)
- {
- // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
- hold = a[(k - 1) * n + (i - 1)];
- a[(k - 1) * n + (i - 1)] = -a[(j - 1) * n + (i - 1)];
- a[(j - 1) * n + (i - 1)] = hold;
- }
- goto L400;
- }
-
- private static void MProd(float[] a, float[] b, float[] c, ref int n)
- {
- int i, j, k;
-
- for (i = 1; i <= n; ++i)
- {
- for (j = 1; j <= n; ++j)
- {
- // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
- c[(i - 1) * n + (j - 1)] = 0.0F;
- for (k = 1; k <= n; ++k)
- {
- c[(i - 1) * n + (j - 1)] = c[(i - 1) * n + (j - 1)] + a[(i - 1) * n + (k - 1)] * b[(k - 1) * n + (j - 1)];
- }
- }
- }
- return;
- }
-
- private static void CompM(float[] a, float[] b, ref int n)
- {
- int i, j;
- float x, sum = 0.0F;
-
- //(starting compare.)
- for (i = 1; i <= n; ++i)
- {
- for (j = 1; j <= n; ++j)
- {
- x = 0.0F;
- if (i == j)
- {
- x = 1.0F;
- }
- sum = sum + System.Math.Abs(System.Math.Abs(a[(i - 1) * n + (j - 1)]) - x);
- }
- }
- return;
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="MatInv4.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// Simultaneous equations by Newton's method adapted from Conte and De Boor
-// to solve F(X,Y)=0 and G(X,Y)=0
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class NewtE
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 1000000;
-#endif
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- double idgb, a, b, x, y, deltaX, deltaY;
- a = 0;
- b = 0;
- x = 0;
- y = 0;
- idgb = 0;
-
- if (idgb != 0)
- {
- System.Console.WriteLine("{0}, {1}, F(x,y) , G(x,y) \n", x, y);
- }
-
- for (int j = 1; j <= Iterations; j++)
- {
- x = 1.0;
- y = (-2.0);
- a = F(x, y);
- b = G(x, y);
- if (idgb != 0)
- {
- System.Console.WriteLine(" {0}, {1}, {2}, {3}\n", x, y, a, b);
- }
-
- for (int i = 1; i <= 20; i++)
- {
- deltaX = (-F(x, y) * GY(x, y) + G(x, y) * FY(x, y)) / (FX(x, y) * GY(x, y) - FY(x, y) * GX(x, y));
- deltaY = (-G(x, y) * FX(x, y) + F(x, y) * GX(x, y)) / (FX(x, y) * GY(x, y) - FY(x, y) * GX(x, y));
- x = x + deltaX;
- y = y + deltaY;
- a = F(x, y);
- b = G(x, y);
- if (idgb != 0)
- {
- System.Console.WriteLine("{0}, {1}, {2}, {3}, {4}\n", i, x, y, a, b);
- }
-
- if ((System.Math.Abs(deltaX) < 0.000001) && (System.Math.Abs(deltaY) < 0.000001) &&
- (System.Math.Abs(a) < 0.000001) && (System.Math.Abs(b) < 0.000001))
- {
- goto L11;
- }
- }
- if (idgb != 0)
- {
- System.Console.WriteLine("FAILED TO CONVERGE IN 20 ITERATIONS\n");
- }
-
- L11:
- {
- }
- }
-
- return true;
- }
-
- private static double F(double x, double y)
- {
- return ((x) + 3 * System.Math.Log(x) / System.Math.Log(10.0) - (y) * (y));
- }
-
- private static double G(double x, double y)
- {
- return (2 * (x) * (x) - (x) * (y) - 5 * (x) + 1);
- }
-
- private static double FX(double x, double y)
- {
- return (1 + 3 / (System.Math.Log(10.0) * (x)));
- }
-
- private static double FY(double x, double y)
- {
- return ((-2) * (y));
- }
-
- private static double GX(double x, double y)
- {
- return (4 * (x) - (y) - 5);
- }
-
- private static double GY(double x, double y)
- {
- return (-(x));
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="NewtE.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// Newton's method adapted from Conte and De Boor
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class NewtR
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 80000000;
-#endif
-
- public static volatile object VolatileObject;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static void Escape(object obj)
- {
- VolatileObject = obj;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- int idbg, iflag;
- double x0, fx0;
-
- iflag = 0;
- idbg = 0;
- fx0 = 0.0;
- x0 = 1.0;
-
- for (int i = 1; i <= Iterations; i++)
- {
- Inner(ref x0, 0.0000001, 0.0000001, 10, out iflag);
- if (iflag > 1)
- {
- goto L888;
- }
-
- fx0 = FF(x0);
- if (idbg != 0)
- {
- System.Console.WriteLine(" THE ROOT IS {0:e} F(ROOT) := {1:E}\n", x0, fx0);
- }
-
- L888:
- {
- }
- }
-
- // Escape iflag, x0, and fx0 so that they appear live
- Escape(iflag);
- Escape(x0);
- Escape(fx0);
-
- return true;
- }
-
- private static double FF(double x)
- {
- return (-1.0 - ((x) * (1.0 - ((x) * (x)))));
- }
-
- private static double FFDer(double x)
- {
- return (3.0 * (x) * (x) - 1.0);
- }
-
- private static void Inner(ref double x0, double xtol, double ftol, int ntol, out int iflag)
- {
- double fx0, deriv, deltax;
-
- iflag = 0;
- for (int n = 1; n <= ntol; n++)
- {
- fx0 = FF(x0);
- if (System.Math.Abs(fx0) < ftol)
- {
- goto L999;
- }
- deriv = FFDer(x0);
-
- if (deriv == 0.0)
- {
- goto L999;
- }
- deltax = fx0 / deriv;
- x0 = x0 - deltax;
- if (System.Math.Abs(deltax) < xtol)
- {
- goto L999;
- }
- }
- L999:
- iflag = 2;
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="NewtR.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// The modified regula-falsi routine adapted from Conte and De Boor
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class Regula
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 4000000;
-#endif
-
- public static volatile object VolatileObject;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static void Escape(object obj)
- {
- VolatileObject = obj;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- double error, fxi;
- double a, b, xi;
- int idbg, iflag;
-
- iflag = 0;
- idbg = 0;
- xi = 0;
- error = 0.0;
- fxi = 0.0;
-
- for (int i = 1; i <= Iterations; i++)
- {
- a = 1.0;
- b = 2.0;
- Inner(ref a, ref b, 0.0000001, 0.0000000001, 30, out iflag);
- if (iflag > 2)
- {
- goto L999;
- }
-
- xi = (a + b) / 2.0;
- error = System.Math.Abs(b - a) / 2.0;
- fxi = FG(xi);
-
- if (idbg != 0)
- {
- System.Console.WriteLine(" the root is {0:E}", xi);
- System.Console.WriteLine(" plus/minus {0}\n", error);
- System.Console.WriteLine(" fg(root):= {0:E}\n", fxi);
- }
-
- L999:
- {
- }
- }
-
- // Escape iflag, xi, error, and fxi so that they appear live
- Escape(iflag);
- Escape(xi);
- Escape(error);
- Escape(fxi);
-
- return true;
- }
-
- private static double FG(double x)
- {
- return (-1.0 - (x * (1.0 - (x * x))));
- }
-
- private static void Inner(ref double a, ref double b, double xtol, double ftol, int ntol, out int iflag)
- {
- double signfa, prevfw, fa, fb, fw, w;
-
- iflag = 0;
- fa = FG(a);
- if (fa < 0.0)
- {
- signfa = -1.0;
- }
- else
- {
- signfa = 1.0;
- }
-
- fb = FG(b);
- if (signfa * fb <= 0.0)
- {
- goto L5;
- }
-
- iflag = 3;
- goto L99;
-
- L5:
- w = a;
- fw = fa;
- for (int i = 1; i <= ntol; i++)
- {
- if (System.Math.Abs(b - a) / 2.0 <= xtol)
- {
- goto L99;
- }
- if (System.Math.Abs(fw) > ftol)
- {
- goto L9;
- }
-
- a = w;
- b = w;
- iflag = 1;
- goto L99;
-
- L9:
- w = (fa * b - fb * a) / (fa - fb);
- if (fw < 0.0)
- {
- prevfw = -1.0;
- }
- else
- {
- prevfw = 1.0;
- }
- fw = FG(w);
-
- if (signfa * fw < 0.0)
- {
- goto L10;
- }
- a = w;
- fa = fw;
- if (fw * prevfw > 0.0)
- {
- fb = fb / 2.0;
- }
- goto L20;
-
- L10:
- b = w;
- fb = fw;
- if (fw * prevfw > 0.0)
- {
- fa = fa / 2.0;
- }
-
- L20:
- {
- }
- }
-
- iflag = 2;
- L99:
- {
- }
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Regula.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// Integration by romberg method adapted from Conte and de Boor
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class Romber
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 640000;
-#endif
-
- private static T[][] AllocArray<T>(int n1, int n2)
- {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i)
- {
- a[i] = new T[n2];
- }
- return a;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- double[][] r = AllocArray<double>(11, 11);
- double[][] t = AllocArray<double>(11, 11);
-
- int idbg, m, n, i, kmax, fourj, j, kmaxm2, l, k, mm1;
- double sum, ratio, t1, h, a, b;
-
- for (l = 1; l <= Iterations; l++)
- {
- idbg = 0;
- m = 2;
- kmax = 6;
- a = 0;
- b = 1;
- h = (b - a) / (m);
- sum = (F(a) + F(b)) / 2;
-
- mm1 = m - 1;
- if (mm1 < 0)
- {
- goto L40;
- }
- if (mm1 == 0)
- {
- goto L10;
- }
- for (i = 1; i <= mm1; i++)
- {
- t1 = a + i * h;
- sum = sum + F(t1);
- }
-
- L10:
- t[1][1] = sum * h;
- if (idbg != 0)
- {
- System.Console.WriteLine(" romberg t-table \n");
- System.Console.WriteLine("{0}\n", t[1][1]);
- }
-
- for (k = 2; k <= kmax; k++)
- {
- h = h / 2;
- n = m * 2;
- sum = 0;
- for (i = 1; i <= n / 2; i++)
- {
- r[k][1] = r[k - 1][1] * System.Math.Sqrt(b * mm1);
- t1 = a + i * h;
- sum = sum + F(t1);
- }
-
- t[k][1] = t[k - 1][1] / 2 + sum * h;
- fourj = 1;
- for (j = 2; j <= k; j++)
- {
- fourj = fourj * 4;
- t[k - 1][j - 1] = t[k][j - 1] - t[k - 1][j - 1];
- t[k][j] = t[k][j - 1] + t[k - 1][j - 1] / (fourj - 1);
- }
-
- if (idbg != 0)
- {
- j = 1;
- System.Console.WriteLine("{0} {1} {2}d\n", t[k][j], j, k);
- }
- }
-
- kmaxm2 = kmax - 2;
- if (kmaxm2 <= 0)
- {
- goto L40;
- }
-
- if (idbg != 0)
- {
- System.Console.WriteLine(" table of ratios \n");
- }
-
- for (k = 1; k <= kmaxm2; k++)
- {
- for (j = 1; j <= k; j++)
- {
- ratio = 0;
- if (System.Math.Abs(t[k + 1][j]) > 0)
- {
- ratio = t[k][j] / t[k + 1][j];
- }
- t[k][j] = ratio;
- }
- }
-
- if (idbg != 0)
- {
- j = 1;
- System.Console.WriteLine("{0} {1} {2}\n", t[k][j], j, k);
- }
-
- L40:
- {
- }
- }
-
- return true;
- }
-
- private static double F(double x)
- {
- return (System.Math.Exp((-(x)) * (x)));
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Romber.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// The secant algorithm adapted from Conte and DeBoor
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class Secant
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 3000000;
-#endif
-
- public static volatile object VolatileObject;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static void Escape(object obj)
- {
- VolatileObject = obj;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- int idbg, iflag;
- double x0, x1, fx1;
-
- iflag = 0;
- idbg = 0;
- x1 = 0;
- fx1 = 0.0;
-
- for (int i = 1; i <= Iterations; i++)
- {
- x0 = 1.0;
- x1 = 2.0;
- Inner(ref x0, ref x1, 0.0000001, 0.0000001, 30, out iflag);
- if (iflag > 1)
- {
- goto L888;
- }
-
- fx1 = FF(x1);
- if (idbg != 0)
- {
- System.Console.WriteLine(" the root is {0:E}, F(ROOT):= {1:E}\n", x1, fx1);
- }
- L888:
- {
- }
- }
-
- // Escape iflag, x1, and fx1 so that they appear live
- Escape(iflag);
- Escape(x1);
- Escape(fx1);
-
- return true;
- }
-
- private static double FF(double x)
- {
- return (-1.0 - (x * (1.0 - (x * x))));
- }
-
- private static void Inner(ref double x0, ref double x1, double xtol, double ftol, int ntol, out int iflag)
- {
- double deltax, deltaf, f0, f1;
-
- iflag = 0;
- f0 = FF(x0);
- deltax = x1 - x0;
-
- for (int n = 1; n <= ntol; n++)
- {
- f1 = FF(x1);
-
- if (System.Math.Abs(f1) <= ftol)
- {
- goto L30;
- }
-
- deltaf = f0 - f1;
- if (deltaf == 0.0)
- {
- goto L999;
- }
-
- deltax = f1 / deltaf * deltax;
- x0 = x1;
- x1 = x1 + deltax;
- if (System.Math.Abs(deltax) <= xtol)
- {
- goto L88;
- }
-
- f0 = f1;
- }
-
- L999:
- iflag = 2;
- goto L88;
- L30:
- iflag = 1;
- L88:
- {
- }
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Secant.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// Integration by Simpson's rule adapted from Conte and de Boor
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class Simpsn
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 90000;
-#endif
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- double a, b, x, s, c, h, hov2, half, t1;
- int idbg, n, nm1;
-
- s = 0;
- idbg = 0;
- if (idbg != 0)
- {
- System.Console.WriteLine("simpsons rule\n");
- }
-
- for (int j = 1; j <= Iterations; j++)
- {
- a = 0;
- b = 1;
- c = 4;
- n = 100;
- h = (b - a) / n;
- hov2 = h / System.Math.Sqrt(c);
- s = 0;
- t1 = a + hov2;
- half = F(t1);
- nm1 = n - 1;
- for (int i = 1; i <= nm1; i++)
- {
- x = a + i * h;
- s = s + F(x);
- t1 = x + hov2;
- half = half + F(t1);
- s = (h / 6) * (F(a) + 4 * half + 2 * s + F(b));
- if (idbg != 0)
- {
- System.Console.WriteLine(" integral from a = {0} to b = {1} for n = {2} is {3}\n", a, b, n, s);
- }
- }
- }
-
- return true;
- }
-
- private static double F(double x)
- {
- return (System.Math.Exp((-(x)) * 2));
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Simpsn.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class SqMtx
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 4000;
-#endif
-
- private const int MatrixSize = 40;
-
- private static T[][] AllocArray<T>(int n1, int n2)
- {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i)
- {
- a[i] = new T[n2];
- }
- return a;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- double[][] a = AllocArray<double>(41, 41);
- double[][] c = AllocArray<double>(41, 41);
-
- int i, j;
-
- for (i = 1; i <= MatrixSize; i++)
- {
- for (j = 1; j <= MatrixSize; j++)
- {
- a[i][j] = i + j;
- }
- }
-
- for (i = 1; i <= Iterations; i++)
- {
- Inner(a, c, MatrixSize);
- }
-
- if (c[1][1] == 23820.0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- private static void Inner(double[][] a, double[][] c, int n)
- {
- for (int i = 1; i <= n; i++)
- {
- for (int j = 1; j <= n; j++)
- {
- c[i][j] = 0.0;
- for (int k = 1; k <= n; k++)
- {
- c[i][j] = c[i][j] + a[i][k] * a[k][j];
- }
- }
- }
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="SqMtx.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// Integration by corrected trapezoid rule adapted from Conte and de Boor
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class Trap
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 240000;
-#endif
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- int nm1, idbg;
- double t2, cortrp, trap, a, b, h;
- trap = 0.0;
- cortrp = 0.0;
-
- idbg = 0;
- for (int j = 1; j <= Iterations; j++)
- {
- a = 0;
- b = 1;
- if (idbg != 0)
- {
- System.Console.WriteLine("trapazoid sum corr.trap sum \n");
- }
-
- for (int n = 10; n <= 15; n++)
- {
- h = (b - a) / n;
- nm1 = n - 1;
- trap = (F(a) + F(b)) / 2;
- for (int i = 1; i <= nm1; i++)
- {
- t2 = a + i * h;
- trap = trap + F(t2);
- }
- trap = trap * h;
- cortrp = trap + h * h * (FPrime(a) - FPrime(b)) / 12;
- if (idbg != 0)
- {
- System.Console.WriteLine("{0}, {1}, {2}\n", n, trap, cortrp);
- }
- }
- }
-
- return true;
- }
-
- private static double F(double x)
- {
- return (System.Math.Exp(-(x) * (x)));
- }
-
- private static double FPrime(double x)
- {
- return ((-2) * (x) * (F(x)));
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Trap.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// C# translation of Whetstone Double Precision Benchmark
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchF
-{
-public static class Whetsto
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 50000;
-#endif
-
- private static int s_j, s_k, s_l;
- private static double s_t, s_t2;
-
- public static volatile int Volatile_out;
-
- private static void Escape(int n, int j, int k, double x1, double x2, double x3, double x4)
- {
- Volatile_out = n;
- Volatile_out = j;
- Volatile_out = k;
- Volatile_out = (int)x1;
- Volatile_out = (int)x2;
- Volatile_out = (int)x3;
- Volatile_out = (int)x4;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- double[] e1 = new double[4];
- double x1, x2, x3, x4, x, y, z, t1;
- int i, n1, n2, n3, n4, n6, n7, n8, n9, n10, n11;
-
- s_t = 0.499975;
- t1 = 0.50025;
- s_t2 = 2.0;
- n1 = 0 * Iterations;
- n2 = 12 * Iterations;
- n3 = 14 * Iterations;
- n4 = 345 * Iterations;
- n6 = 210 * Iterations;
- n7 = 32 * Iterations;
- n8 = 899 * Iterations;
- n9 = 616 * Iterations;
- n10 = 0 * Iterations;
- n11 = 93 * Iterations;
- x1 = 1.0;
- x2 = x3 = x4 = -1.0;
-
- for (i = 1; i <= n1; i += 1)
- {
- x1 = (x1 + x2 + x3 - x4) * s_t;
- x2 = (x1 + x2 - x3 - x4) * s_t;
- x3 = (x1 - x2 + x3 + x4) * s_t;
- x4 = (-x1 + x2 + x3 + x4) * s_t;
- }
- Escape(n1, n1, n1, x1, x2, x3, x4);
-
- /* MODULE 2: array elements */
- e1[0] = 1.0;
- e1[1] = e1[2] = e1[3] = -1.0;
- for (i = 1; i <= n2; i += 1)
- {
- e1[0] = (e1[0] + e1[1] + e1[2] - e1[3]) * s_t;
- e1[1] = (e1[0] + e1[1] - e1[2] + e1[3]) * s_t;
- e1[2] = (e1[0] - e1[1] + e1[2] + e1[3]) * s_t;
- e1[3] = (-e1[0] + e1[1] + e1[2] + e1[3]) * s_t;
- }
- Escape(n2, n3, n2, e1[0], e1[1], e1[2], e1[3]);
-
- /* MODULE 3: array as parameter */
- for (i = 1; i <= n3; i += 1)
- {
- PA(e1);
- }
- Escape(n3, n2, n2, e1[0], e1[1], e1[2], e1[3]);
-
- /* MODULE 4: conditional jumps */
- s_j = 1;
- for (i = 1; i <= n4; i += 1)
- {
- if (s_j == 1)
- {
- s_j = 2;
- }
- else
- {
- s_j = 3;
- }
- if (s_j > 2)
- {
- s_j = 0;
- }
- else
- {
- s_j = 1;
- }
- if (s_j < 1)
- {
- s_j = 1;
- }
- else
- {
- s_j = 0;
- }
- }
- Escape(n4, s_j, s_j, x1, x2, x3, x4);
-
- /* MODULE 5: omitted */
- /* MODULE 6: integer Math */
- s_j = 1;
- s_k = 2;
- s_l = 3;
- for (i = 1; i <= n6; i += 1)
- {
- s_j = s_j * (s_k - s_j) * (s_l - s_k);
- s_k = s_l * s_k - (s_l - s_j) * s_k;
- s_l = (s_l - s_k) * (s_k + s_j);
- e1[s_l - 2] = s_j + s_k + s_l;
- e1[s_k - 2] = s_j * s_k * s_l;
- }
- Escape(n6, s_j, s_k, e1[0], e1[1], e1[2], e1[3]);
-
- /* MODULE 7: trig. functions */
- x = y = 0.5;
- for (i = 1; i <= n7; i += 1)
- {
- x = s_t * System.Math.Atan(s_t2 * System.Math.Sin(x) * System.Math.Cos(x) / (System.Math.Cos(x + y) + System.Math.Cos(x - y) - 1.0));
- y = s_t * System.Math.Atan(s_t2 * System.Math.Sin(y) * System.Math.Cos(y) / (System.Math.Cos(x + y) + System.Math.Cos(x - y) - 1.0));
- }
- Escape(n7, s_j, s_k, x, x, y, y);
-
- /* MODULE 8: procedure calls */
- x = y = z = 1.0;
- for (i = 1; i <= n8; i += 1)
- {
- P3(x, y, out z);
- }
- Escape(n8, s_j, s_k, x, y, z, z);
-
- /* MODULE9: array references */
- s_j = 1;
- s_k = 2;
- s_l = 3;
- e1[0] = 1.0;
- e1[1] = 2.0;
- e1[2] = 3.0;
- for (i = 1; i <= n9; i += 1)
- {
- P0(e1);
- }
- Escape(n9, s_j, s_k, e1[0], e1[1], e1[2], e1[3]);
-
- /* MODULE10: integer System.Math */
- s_j = 2;
- s_k = 3;
- for (i = 1; i <= n10; i += 1)
- {
- s_j = s_j + s_k;
- s_k = s_j + s_k;
- s_j = s_k - s_j;
- s_k = s_k - s_j - s_j;
- }
- Escape(n10, s_j, s_k, x1, x2, x3, x4);
-
- /* MODULE11: standard functions */
- x = 0.75;
- for (i = 1; i <= n11; i += 1)
- {
- x = System.Math.Sqrt(System.Math.Exp(System.Math.Log(x) / t1));
- }
- Escape(n11, s_j, s_k, x, x, x, x);
-
- return true;
- }
-
- private static void PA(double[] e)
- {
- int j;
- j = 0;
- lab:
- e[0] = (e[0] + e[1] + e[2] - e[3]) * s_t;
- e[1] = (e[0] + e[1] - e[2] + e[3]) * s_t;
- e[2] = (e[0] - e[1] + e[2] + e[3]) * s_t;
- e[3] = (-e[0] + e[1] + e[2] + e[3]) / s_t2;
- j += 1;
- if (j < 6)
- {
- goto lab;
- }
- }
-
- private static void P3(double x, double y, out double z)
- {
- x = s_t * (x + y);
- y = s_t * (x + y);
- z = (x + y) / s_t2;
- }
-
- private static void P0(double[] e1)
- {
- e1[s_j] = e1[s_k];
- e1[s_k] = e1[s_l];
- e1[s_l] = e1[s_j];
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Whetsto.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class EightQueens
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 100000;
-#endif
-
- static int[] m_c = new int[15];
- static int[] m_x = new int[9];
-
- static void TryMe(int i, ref int q, int[] a, int[] b)
- {
- int j = 0;
- q = 0;
- while ((q == 0) && (j != 8)) {
- j = j + 1;
- q = 0;
- if ((b[j] == 1) && (a[i + j] == 1) && (m_c[i - j + 7] == 1)) {
- m_x[i] = j;
- b[j] = 0;
- a[i + j] = 0;
- m_c[i - j + 7] = 0;
- if (i < 8) {
- TryMe(i + 1, ref q, a, b);
- if (q == 0) {
- b[j] = 1;
- a[i + j] = 1;
- m_c[i - j + 7] = 1;
- }
- }
- else {
- q = 1;
- }
- }
- }
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- int[] a = new int[9];
- int[] b = new int[17];
- int q = 0;
- int i = 0;
- while (i <= 16) {
- if ((i >= 1) && (i <= 8)) {
- a[i] = 1;
- }
- if (i >= 2) {
- b[i] = 1;
- }
- if (i <= 14) {
- m_c[i] = 1;
- }
- i = i + 1;
- }
-
- TryMe(1, ref q, b, a);
-
- return (q == 1);
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench();
- }
- }
- }
- }
-
- static bool TestBase() {
- bool result = true;
- for (int i = 0; i < Iterations; i++) {
- result &= Bench();
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="8Queens.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class Ackermann
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 100000;
-#endif
-
- static int Acker(int m, int n) {
- if (m == 0) {
- return n + 1;
- }
- else if (n == 0) {
- return Acker(m - 1, 1);
- }
- else {
- return Acker(m - 1, Acker(m, n - 1));
- }
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- int a00 = Acker(0, 0);
- int a11 = Acker(1, 1);
- int a22 = Acker(2, 2);
- int a33 = Acker(3, 3);
- return (a00 == 1) && (a11 == 3) && (a22 == 7) & (a33 == 61);
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench();
- }
- }
- }
- }
-
- static bool TestBase() {
- bool result = true;
- for (int i = 0; i < Iterations; i++) {
- result &= Bench();
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Ackermann.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class AddArray
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 15000;
-#endif
-
- const int Size = 6000;
-
- public static volatile object VolatileObject;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static void Escape(object obj) {
- VolatileObject = obj;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
-
- int[] flags1 = new int[Size + 1];
- int[] flags2 = new int[Size + 1];
- int[] flags3 = new int[Size + 1];
- int[] flags4 = new int[Size + 1];
-
- int j, k, l, m;
-
- for (j = 0; j <= Size; j++) {
- flags1[j] = 70000 + j;
- k = j;
- flags2[k] = flags1[j] + k + k;
- l = j;
- flags3[l] = flags2[k] + l + l + l;
- m = j;
- flags4[m] = flags3[l] + m + m + m + m;
- }
-
- for (j = 0; j <= Size; j++) {
- k = j;
- l = j;
- m = j;
- flags1[j] = flags1[j] + flags2[k] + flags3[l] + flags4[m] - flags2[k - j + l];
- }
-
- // Escape each flags array so that their elements will appear live-out
- Escape(flags1);
- Escape(flags2);
- Escape(flags3);
- Escape(flags4);
-
- return true;
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench();
- }
- }
- }
- }
-
- static bool TestBase() {
- bool result = true;
- for (int i = 0; i < Iterations; i++) {
- result &= Bench();
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AddArray.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class AddArray2
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 50;
-#endif
-
- private const int Dim = 200;
-
- private static T[][] AllocArray<T>(int n1, int n2)
- {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i)
- {
- a[i] = new T[n2];
- }
- return a;
- }
-
- private static
- void BenchInner1(int[][] a, ref int nn)
- {
- int n;
- int l, m;
- n = nn;
- for (int i = 1; i <= n; i++)
- {
- for (int j = (i + 1); j <= n; j++)
- {
- for (int k = 1; k <= n; k++)
- {
- l = a[i][k];
- m = a[j][k];
- unchecked
- {
- a[j][k] = l + m;
- }
- }
- }
- }
- }
-
- private static
- void BenchInner2(int[][] a, ref int nn)
- {
- int n;
- int l, m;
- n = nn;
- for (int i = 1; i <= n; i++)
- {
- for (int j = (i + 1); j <= n; j++)
- {
- for (int k = 1; k <= n; k++)
- {
- l = a[k][i];
- m = a[k][j];
- unchecked
- {
- a[k][j] = l + m;
- }
- }
- }
- }
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench(int[][] a)
- {
- int n = Dim;
- for (int i = 1; i <= n; i++)
- {
- for (int j = 1; j <= n; j++)
- {
- a[i][j] = i + j;
- }
- }
-
- BenchInner1(a, ref n);
- n = Dim;
- BenchInner2(a, ref n);
-
- return true;
- }
-
- [Benchmark]
- public static void Test()
- {
- int[][] array = AllocArray<int>(Dim + 1, Dim + 1);
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- for (int i = 1; i <= Iterations; i++)
- {
- Bench(array);
- }
- }
- }
- }
-
- private static bool TestBase()
- {
- int[][] array = AllocArray<int>(Dim + 1, Dim + 1);
- bool result = true;
- for (int i = 1; i <= Iterations; i++)
- {
- result &= Bench(array);
- }
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AddArray2.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// The sorting benchmark calls a random number generator the number
-// of times specified by Maxnum to create an array of int integers,
-// then does a quicksort on the array of ints. Random numbers
-// are produced using a multiplicative modulus method with known
-// seed, so that the generated array is constant across compilers.
-//
-// This is adapted from a benchmark in BYTE Magazine, August 1984.
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class Array1
-{
-#if DEBUG
- private const int Iterations = 1;
- private const int Maxnum = 100;
-#else
- private const int Iterations = 125;
- private const int Maxnum = 1000;
-#endif
-
- private const int Modulus = ((int)0x20000);
- private const int C = 13849;
- private const int A = 25173;
- static int s_seed = 7;
-
- private static void Quick(int lo, int hi, int[] input)
- {
- int i, j;
- int pivot, temp;
-
- if (lo < hi)
- {
- // 0 <= lo < hi
- for (i = lo, j = (hi + 1), pivot = input[lo]; ;)
- {
- do
- {
- ++i;
- } while (input[i] < pivot);
-
- do
- {
- --j;
- // Accessing upto hi
- } while (input[j] > pivot);
-
- if (i < j)
- {
- temp = input[i];
- input[i] = input[j];
- input[j] = temp;
- }
- else
- {
- break;
- }
- }
- temp = input[j];
- input[j] = input[lo];
- input[lo] = temp;
- Quick(lo, j - 1, input);
- Quick(j + 1, hi, input);
- }
- }
-
- private static int Random(int size)
- {
- unchecked
- {
- s_seed = s_seed * A + C;
- }
-
- return (s_seed % size);
- }
-
- private static bool VerifySort(int[] buffer)
- {
- for (int y = 0; y < Maxnum - 2; y++)
- {
- if (buffer[y] > buffer[y + 1])
- {
- return false;
- }
- }
- return true;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- int[] buffer = new int[Maxnum + 1];
-
- for (int i = 0; i < Iterations; ++i)
- {
- for (int j = 0; j < Maxnum; ++j)
- {
- int temp = Random(Modulus);
- if (temp < 0L)
- {
- temp = (-temp);
- }
- buffer[j] = temp;
- }
- buffer[Maxnum] = Modulus;
-
- Quick(0, Maxnum - 1, buffer);
- }
-
- bool result = VerifySort(buffer);
-
- return result;
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Iterations; i++)
- {
- Bench();
- }
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = true;
- for (int i = 0; i < Iterations; i++)
- {
- result &= Bench();
- }
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Array1.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class Array2
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 500000;
-#endif
-
- static T[][][] AllocArray<T>(int n1, int n2, int n3) {
- T[][][] a = new T[n1][][];
- for (int i = 0; i < n1; ++i) {
- a[i] = new T[n2][];
- for (int j = 0; j < n2; j++) {
- a[i][j] = new T[n3];
- }
- }
-
- return a;
- }
-
- static void Initialize(int[][][] s) {
- for (int i = 0; i < 10; i++) {
- for (int j = 0; j < 10; j++) {
- for (int k = 0; k < 10; k++) {
- s[i][j][k] = (2 * i) - (3 * j) + (5 * k);
- }
- }
- }
- }
-
- static bool VerifyCopy(int[][][] s, int[][][] d) {
- for (int i = 0; i < 10; i++) {
- for (int j = 0; j < 10; j++) {
- for (int k = 0; k < 10; k++) {
- if (s[i][j][k] != d[i][j][k]) {
- return false;
- }
- }
- }
- }
-
- return true;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench(int loop) {
-
- int[][][] s = AllocArray<int>(10, 10, 10);
- int[][][] d = AllocArray<int>(10, 10, 10);
-
- Initialize(s);
-
- for (; loop != 0; loop--) {
- for (int i = 0; i < 10; i++) {
- for (int j = 0; j < 10; j++) {
- for (int k = 0; k < 10; k++) {
- d[i][j][k] = s[i][j][k];
- }
- }
- }
- }
-
- bool result = VerifyCopy(s, d);
-
- return result;
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- Bench(Iterations);
- }
- }
- }
-
- static bool TestBase() {
- bool result = Bench(Iterations);
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Array2.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class BenchE
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 5000000;
-#endif
-
- private static int s_position;
-
- private static int Strsch(char[] s, char[] k, int ns, int nk)
- {
- int i, j;
- int start, ksave, cont;
- int kend, ssave;
- int r;
-
- start = 0;
- ksave = 0;
- cont = ns - nk + start;
- kend = ksave + nk - 1;
- i = 0;
- j = 0;
- top:
- while (s[i] != k[j])
- {
- // s is accessed upto cont i.e. ns - nk + 0
- if (i >= cont)
- {
- r = -1;
- goto bottom;
- }
- i = i + 1;
- }
- ssave = i;
- j = j + 1;
- while (j <= kend)
- {
- i = i + 1;
- // j <= kend, so k is accessed upto 0 + nk - 1
- if (s[i] != k[j])
- {
- i = ssave + 1;
- j = ksave;
- goto top;
- }
- j = j + 1;
- }
- r = ssave - start + 1;
- bottom:
- return r;
- }
-
- private static void BenchInner(char[] s, char[] k)
- {
- int ns, nk;
-
- ns = 120;
- nk = 15;
- s_position = Strsch(s, k, ns, nk);
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static bool Bench()
- {
- char[] s = {
- '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'H', 'E', 'R', 'E', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
- 'H', 'E', 'R', 'E', ' ', 'I', 'S', ' ', 'A', ' ', 'M', 'A', 'T', 'C', 'H', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'
- };
-
- char[] k = { 'H', 'E', 'R', 'E', ' ', 'I', 'S', ' ', 'A', ' ', 'M', 'A', 'T', 'C', 'H', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' };
-
- for (int i = 0; i < Iterations; i++)
- {
- BenchInner(s, k);
- }
-
- return (s_position == 91);
- }
-
- [Benchmark]
- public static void Test()
- {
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- bool result = Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="BenchE.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class BubbleSort
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 55000;
-#endif
-
- static void SortArray(int[] tab, int last) {
- bool swap;
- int temp;
- do {
- swap = false;
- for (int i = 0; i < last; i++) {
- if (tab[i] > tab[i + 1]) {
- temp = tab[i];
- tab[i] = tab[i + 1];
- tab[i + 1] = temp;
- swap = true;
- }
- }
- }
- while (swap);
- }
-
- static bool VerifySort(int[] tab, int last) {
- for (int i = 0; i < last; i++) {
- if (tab[i] > tab[i + 1]) {
- return false;
- }
- }
-
- return true;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static public bool Bench() {
- int[] tab = new int[100];
- int k = 0;
- for (int i = 9; i >= 0; i--) {
- for (int j = i * 10; j < (i + 1) * 10; j++) {
- tab[k++] = ((j & 1) == 1) ? j + 1 : j - 1;
- }
- }
- SortArray(tab, 99);
- bool result = VerifySort(tab, 99);
- return result;
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench();
- }
- }
- }
- }
-
- static bool TestBase() {
- bool result = true;
- for (int i = 0; i < Iterations; i++) {
- result &= Bench();
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="BubbleSort.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class BubbleSort2
-{
-
-#if DEBUG
- public const int Iterations = 1;
- public const int Bound = 5 * Iterations;
-#else
- public const int Iterations = 15;
- public const int Bound = 500 * Iterations;
-#endif
-
- static void Inner(int[] x) {
- int limit1 = Bound - 1;
- for (int i = 1; i <= limit1; i++) {
- for (int j = i; j <= Bound; j++) {
- if (x[i] > x[j]) {
- int temp = x[j];
- x[j] = x[i];
- x[i] = temp;
- }
- }
- }
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- int[] x = new int[Bound + 1];
- int i, j;
- int limit;
- j = 99999;
- limit = Bound - 2;
- i = 1;
- do {
- x[i] = j & 32767;
- x[i + 1] = (j + 11111) & 32767;
- x[i + 2] = (j + 22222) & 32767;
- j = j + 33333;
- i = i + 3;
- } while (i <= limit);
- x[Bound - 1] = j;
- x[Bound] = j;
-
- Inner(x);
-
- for (i = 0; i < Bound - 1; i++) {
- if (x[i] > x[i + 1]) {
- return false;
- }
- }
-
- return true;
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench();
- }
- }
- }
- }
-
- static bool TestBase() {
- bool result = true;
- for (int i = 0; i < Iterations; i++) {
- result &= Bench();
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="BubbleSort2.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// Based on Eratosthenes Sieve Prime Number Program in C, Byte Magazine, January 1983.
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class CSieve
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 200;
-#endif
-
- const int Size = 8190;
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- bool[] flags = new bool[Size + 1];
- int count = 0;
- for (int iter = 1; iter <= Iterations; iter++)
- {
- count = 0;
-
- // Initially, assume all are prime
- for (int i = 0; i <= Size; i++)
- {
- flags[i] = true;
- }
-
- // Refine
- for (int i = 2; i <= Size; i++)
- {
- if (flags[i])
- {
- // Found a prime
- for (int k = i + i; k <= Size; k += i)
- {
- // Cancel its multiples
- flags[k] = false;
- }
- count++;
- }
- }
- }
-
- return (count == 1027);
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench();
- }
- }
- }
- }
-
- static bool TestBase() {
- bool result = true;
- for (int i = 0; i < Iterations; i++) {
- result &= Bench();
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="CSieve.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class Fib
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 3500;
-#endif
-
- const int Number = 24;
-
- static int Fibonacci(int x) {
- if (x > 2) {
- return (Fibonacci(x - 1) + Fibonacci(x - 2));
- }
- else {
- return 1;
- }
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- int fib = Fibonacci(Number);
- return (fib == 46368);
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench();
- }
- }
- }
- }
-
- static bool TestBase() {
- bool result = true;
- for (int i = 0; i < Iterations; i++) {
- result &= Bench();
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Fib.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class HeapSort
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 2500;
-#endif
-
- const int ArraySize = 5500;
-
- static void Inner(int[] x, int n) {
- int i, j, k, m;
-
- // pass1 -- put vector in heap form
- // that is to say, guarantee that x(i)>=x(2*i) and x(i)>=x(2*i+1).
- // after pass 1, the largest item will be at x(1).
- for (i = 2; i <= n; i++) {
- j = i;
- k = j / 2;
- m = x[i];
-
- // 0 < k <= (n / 2)
- // 1 <= j <= n
- while (k > 0) {
- if (m <= x[k]) {
- break;
- }
- x[j] = x[k];
- j = k;
- k = k / 2;
- }
- x[j] = m;
- }
-
- // pass 2 -- swap first and last items. now with the last
- // item correctly placed, consider the list shorter by one item.
- // restore the shortened list to heap sort, and repeat
- // process until list is only two items long.
- i = n;
- do {
- // do i = n to 2 by -1;
- m = x[i];
- x[i] = x[1]; // last item, i.e. item(i) now correct.
- j = 1; // we now find the appropriate resting point for m
- k = 2;
-
- // 2 <= k < i ==> 2 <= k < n
- // 1 <= j < n
- while (k < i) {
- if ((k + 1) < i) {
- if (x[k + 1] > x[k]) {
- k = k + 1;
- }
- }
- if (x[k] <= m) {
- break;
- }
-
- x[j] = x[k];
- j = k;
- k = k + k;
- }
-
- x[j] = m;
- i = i - 1;
- } while (i >= 2);
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- int[] x = new int[ArraySize + 1];
- for (int i = 1; i <= ArraySize; i++) {
- x[i] = ArraySize - i + 1;
- }
- Inner(x, ArraySize);
- for (int j = 1; j <= ArraySize; j++) {
- if (x[j] != j) {
- return false;
- }
- }
- return true;
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench();
- }
- }
- }
- }
-
- static bool TestBase() {
- bool result = true;
- for (int i = 0; i < Iterations; i++) {
- result &= Bench();
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="HeapSort.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class IniArray
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 10000000;
-#endif
-
- const int Allotted = 16;
- static volatile object VolatileObject;
-
- static void Escape(object obj) {
- VolatileObject = obj;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- char[] workarea = new char[Allotted];
- for (int i = 0; i < Iterations; i++) {
- for (int j = 0; j < Allotted; j++) {
- workarea[j] = ' ';
- }
- }
- Escape(workarea);
- return true;
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- Bench();
- }
- }
- }
-
- static bool TestBase() {
- bool result = Bench();
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="IniArray.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class LogicArray
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 3000;
-#endif
-
- const int ArraySize = 50;
-
- struct Workarea
- {
- public int X;
- public int[][] A;
- }
-
- static T[][] AllocArray<T>(int n1, int n2) {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i) {
- a[i] = new T[n2];
- }
- return a;
- }
-
- static bool Inner(ref Workarea cmn) {
- int i, j, k;
- cmn.X = 0;
- for (i = 1; i <= 50; i++) {
- for (j = 1; j <= 50; j++) {
- cmn.A[i][j] = 1;
- }
- }
- for (k = 1; k <= 50; k++) {
- for (j = 1; j <= 50; j++) {
- i = 1;
- do {
- cmn.X = cmn.X | cmn.A[i][j] & cmn.A[i + 1][k];
- i = i + 2;
- } while (i <= 50);
- }
- }
- if (cmn.X != 1) {
- return false;
- }
- else {
- return true;
- }
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- Workarea cmn = new Workarea();
- cmn.X = 0;
- cmn.A = AllocArray<int>(51, 51);
- for (int n = 1; n <= Iterations; n++) {
- bool result = Inner(ref cmn);
- if (!result) {
- return false;
- }
- }
-
- return true;
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- Bench();
- }
- }
- }
-
- static bool TestBase() {
- bool result = Bench();
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="LogicArray.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class Midpoint
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 70000;
-#endif
-
- static T[][] AllocArray<T>(int n1, int n2) {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i) {
- a[i] = new T[n2];
- }
- return a;
- }
-
- static int Inner(ref int x, ref int y, ref int z) {
- int mid;
-
- if (x < y) {
- if (y < z) {
- mid = y;
- }
- else {
- if (x < z) {
- mid = z;
- }
- else {
- mid = x;
- }
- }
- }
- else {
- if (x < z) {
- mid = x;
- }
- else {
- if (y < z) {
- mid = z;
- }
- else {
- mid = y;
- }
- }
- }
-
- return (mid);
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- int[][] a = AllocArray<int>(2001, 4);
- int[] mid = new int[2001];
- int j = 99999;
-
- for (int i = 1; i <= 2000; i++) {
- a[i][1] = j & 32767;
- a[i][2] = (j + 11111) & 32767;
- a[i][3] = (j + 22222) & 32767;
- j = j + 33333;
- }
-
- for (int k = 1; k <= Iterations; k++) {
- for (int l = 1; l <= 2000; l++) {
- mid[l] = Inner(ref a[l][1], ref a[l][2], ref a[l][3]);
- }
- }
-
- return (mid[2000] == 17018);
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- Bench();
- }
- }
- }
-
- static bool TestBase() {
- bool result = Bench();
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Midpoint.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class MulMatrix
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 100;
-#endif
-
- const int Size = 75;
- static volatile object VolatileObject;
-
- static void Escape(object obj) {
- VolatileObject = obj;
- }
-
- static T[][] AllocArray<T>(int n1, int n2) {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i) {
- a[i] = new T[n2];
- }
- return a;
- }
-
- static void Inner(int[][] a, int[][] b, int[][] c) {
-
- int i, j, k, l;
-
- // setup
- for (j = 0; j < Size; j++) {
- for (i = 0; i < Size; i++) {
- a[i][j] = i;
- b[i][j] = 2 * j;
- c[i][j] = a[i][j] + b[i][j];
- }
- }
-
- // jkl
- for (j = 0; j < Size; j++) {
- for (k = 0; k < Size; k++) {
- for (l = 0; l < Size; l++) {
- c[j][k] += a[j][l] * b[l][k];
- }
- }
- }
-
- // jlk
- for (j = 0; j < Size; j++) {
- for (l = 0; l < Size; l++) {
- for (k = 0; k < Size; k++) {
- c[j][k] += a[j][l] * b[l][k];
- }
- }
- }
-
- // kjl
- for (k = 0; k < Size; k++) {
- for (j = 0; j < Size; j++) {
- for (l = 0; l < Size; l++) {
- c[j][k] += a[j][l] * b[l][k];
- }
- }
- }
-
- // klj
- for (k = 0; k < Size; k++) {
- for (l = 0; l < Size; l++) {
- for (j = 0; j < Size; j++) {
- c[j][k] += a[j][l] * b[l][k];
- }
- }
- }
-
- // ljk
- for (l = 0; l < Size; l++) {
- for (j = 0; j < Size; j++) {
- for (k = 0; k < Size; k++) {
- c[j][k] += a[j][l] * b[l][k];
- }
- }
- }
-
- // lkj
- for (l = 0; l < Size; l++) {
- for (k = 0; k < Size; k++) {
- for (j = 0; j < Size; j++) {
- c[j][k] += a[j][l] * b[l][k];
- }
- }
- }
-
- return;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- int[][] a = AllocArray<int>(Size, Size);
- int[][] b = AllocArray<int>(Size, Size);
- int[][] c = AllocArray<int>(Size, Size);
-
- for (int i = 0; i < Iterations; ++i) {
- Inner(a, b, c);
- }
-
- Escape(c);
- return true;
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- Bench();
- }
- }
- }
-
- static bool TestBase() {
- bool result = Bench();
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="MulMatrix.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// Adapted from
-//
-// Dhrystone: a synthetic systems programming benchmark
-// Reinhold P. Weicker
-// Communications of the ACM, Volume 27 Issue 10, Oct 1984, Pages 1013-1030
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class NDhrystone
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 7000000;
-#endif
-
- static T[][] AllocArray<T>(int n1, int n2) {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i) {
- a[i] = new T[n2];
- }
- return a;
- }
-
- enum Enumeration
- {
- Ident1 = 1, Ident2, Ident3, Ident4, Ident5
- }
-
- sealed class Record
- {
- public Record PtrComp;
- public Enumeration Discr;
- public Enumeration EnumComp;
- public int IntComp;
- public char[] StringComp;
- }
-
- static int s_intGlob;
- static bool s_boolGlob;
- static char s_char1Glob;
- static char s_char2Glob;
- static int[] m_array1Glob = new int[51];
- static int[][] m_array2Glob;
- static Record m_ptrGlb = new Record();
- static Record m_ptrGlbNext = new Record();
- static char[] m_string1Loc;
- static char[] m_string2Loc;
-
- static void Proc0() {
- int intLoc1;
- int intLoc2;
- int intLoc3 = 0;
- Enumeration enumLoc;
-
- int i; /* modification */
-
- m_ptrGlb.PtrComp = m_ptrGlbNext;
- m_ptrGlb.Discr = Enumeration.Ident1;
- m_ptrGlb.EnumComp = Enumeration.Ident3;
- m_ptrGlb.IntComp = 40;
- m_ptrGlb.StringComp = "DHRYSTONE PROGRAM, SOME STRING".ToCharArray();
- m_string1Loc = "DHRYSTONE PROGRAM, 1'ST STRING".ToCharArray();
- m_array2Glob[8][7] = 10; /* Was missing in published program */
-
- for (i = 0; i < Iterations; ++i) {
- Proc5();
- Proc4();
- intLoc1 = 2;
- intLoc2 = 3;
- m_string2Loc = "DHRYSTONE PROGRAM, 2'ND STRING".ToCharArray();
- enumLoc = Enumeration.Ident2;
- s_boolGlob = !Func2(m_string1Loc, m_string2Loc);
- while (intLoc1 < intLoc2) {
- intLoc3 = 5 * intLoc1 - intLoc2;
- Proc7(intLoc1, intLoc2, ref intLoc3);
- ++intLoc1;
- }
- Proc8(m_array1Glob, m_array2Glob, intLoc1, intLoc3);
- Proc1(ref m_ptrGlb);
- for (char charIndex = 'A'; charIndex <= s_char2Glob; ++charIndex) {
- if (enumLoc == Func1(charIndex, 'C')) {
- Proc6(Enumeration.Ident1, ref enumLoc);
- }
- }
- intLoc3 = intLoc2 * intLoc1;
- intLoc2 = intLoc3 / intLoc1;
- intLoc2 = 7 * (intLoc3 - intLoc2) - intLoc1;
- Proc2(ref intLoc1);
- }
- }
-
- static void Proc1(ref Record ptrParIn) {
- ptrParIn.PtrComp = m_ptrGlb;
- ptrParIn.IntComp = 5;
- ptrParIn.PtrComp.IntComp = ptrParIn.IntComp;
- ptrParIn.PtrComp.PtrComp = ptrParIn.PtrComp;
- Proc3(ref ptrParIn.PtrComp.PtrComp);
- if (ptrParIn.PtrComp.Discr == Enumeration.Ident1) {
- ptrParIn.PtrComp.IntComp = 6;
- Proc6(ptrParIn.EnumComp, ref ptrParIn.PtrComp.EnumComp);
- ptrParIn.PtrComp.PtrComp = m_ptrGlb.PtrComp;
- Proc7(ptrParIn.PtrComp.IntComp, 10, ref ptrParIn.PtrComp.IntComp);
- }
- else {
- ptrParIn = ptrParIn.PtrComp;
- }
- }
-
- static void Proc2(ref int intParIO) {
- int intLoc;
- Enumeration enumLoc = Enumeration.Ident2;
- intLoc = intParIO + 10;
-
- for (;;) {
- if (s_char1Glob == 'A') {
- --intLoc;
- intParIO = intLoc - s_intGlob;
- enumLoc = Enumeration.Ident1;
- }
- if (enumLoc == Enumeration.Ident1) {
- break;
- }
- }
- }
-
- static void Proc3(ref Record ptrParOut) {
- if (m_ptrGlb != null) {
- ptrParOut = m_ptrGlb.PtrComp;
- }
- else {
- s_intGlob = 100;
- }
-
- Proc7(10, s_intGlob, ref m_ptrGlb.IntComp);
- }
-
- static void Proc4() {
- bool boolLoc;
- boolLoc = s_char1Glob == 'A';
- boolLoc |= s_boolGlob;
- s_char2Glob = 'B';
- }
-
- static void Proc5() {
- s_char1Glob = 'A';
- s_boolGlob = false;
- }
-
- static void Proc6(Enumeration enumParIn, ref Enumeration enumParOut) {
- enumParOut = enumParIn;
- if (!Func3(enumParIn)) {
- enumParOut = Enumeration.Ident4;
- }
-
- switch (enumParIn) {
- case Enumeration.Ident1:
- enumParOut = Enumeration.Ident1;
- break;
- case Enumeration.Ident2:
- if (s_intGlob > 100) {
- enumParOut = Enumeration.Ident1;
- }
- else {
- enumParOut = Enumeration.Ident4;
- }
- break;
- case Enumeration.Ident3:
- enumParOut = Enumeration.Ident2;
- break;
- case Enumeration.Ident4:
- break;
- case Enumeration.Ident5:
- enumParOut = Enumeration.Ident3;
- break;
- }
- }
-
- static void Proc7(int intParI1, int intParI2, ref int intParOut) {
- int intLoc;
- intLoc = intParI1 + 2;
- intParOut = intParI2 + intLoc;
- }
-
- static void Proc8(int[] array1Par, int[][] array2Par, int intParI1, int intParI2) {
- int intLoc;
- intLoc = intParI1 + 5;
- array1Par[intLoc] = intParI2;
- array1Par[intLoc + 1] = array1Par[intLoc];
- array1Par[intLoc + 30] = intLoc;
- for (int intIndex = intLoc; intIndex <= (intLoc + 1); ++intIndex) {
- array2Par[intLoc][intIndex] = intLoc;
- }
- ++array2Par[intLoc][intLoc - 1];
- array2Par[intLoc + 20][intLoc] = array1Par[intLoc];
- s_intGlob = 5;
- }
-
- static Enumeration Func1(char charPar1, char charPar2) {
- char charLoc1;
- char charLoc2;
- charLoc1 = charPar1;
- charLoc2 = charLoc1;
- if (charLoc2 != charPar2) {
- return (Enumeration.Ident1);
- }
- else {
- return (Enumeration.Ident2);
- }
- }
-
- static bool Func2(char[] strParI1, char[] strParI2) {
- int intLoc;
- char charLoc = '\0';
- intLoc = 1;
- while (intLoc <= 1) {
- if (Func1(strParI1[intLoc], strParI2[intLoc + 1]) == Enumeration.Ident1) {
- charLoc = 'A';
- ++intLoc;
- }
- }
- if (charLoc >= 'W' && charLoc <= 'Z') {
- intLoc = 7;
- }
- if (charLoc == 'X') {
- return true;
- }
- else {
- for (int i = 0; i < 30; i++) {
- if (strParI1[i] > strParI2[i]) {
- intLoc += 7;
- return true;
- }
- }
-
- return false;
- }
- }
-
- static bool Func3(Enumeration enumParIn) {
- Enumeration enumLoc;
- enumLoc = enumParIn;
- if (enumLoc == Enumeration.Ident3) {
- return true;
- }
-
- return false;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- m_array2Glob = AllocArray<int>(51, 51);
- Proc0();
- return true;
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- Bench();
- }
- }
- }
-
- static bool TestBase() {
- bool result = Bench();
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="NDhrystone.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public class Permutate
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 20000;
-#endif
-
- private int[] _permArray = new int[11];
- private static int s_pctr;
-
- private static
- void Swap(int[] arr, int i, int j)
- {
- int t = arr[i];
- arr[i] = arr[j];
- arr[j] = t;
- }
-
- private void Initialize()
- {
- for (int i = 1; i <= 7; i++)
- {
- _permArray[i] = i - 1;
- }
- }
-
- private void PermuteArray(int n)
- {
- int k;
- s_pctr = s_pctr + 1;
- if (n != 1)
- {
- PermuteArray(n - 1);
- for (k = n - 1; k >= 1; k--)
- {
- Swap(_permArray, n, k);
- PermuteArray(n - 1);
- Swap(_permArray, n, k);
- }
- }
- }
-
- private bool Validate()
- {
- int k = 0;
-
- for (int i = 0; i <= 6; i++)
- {
- for (int j = 1; j <= 7; j++)
- {
- if (_permArray[j] == i)
- {
- k = k + 1;
- }
- }
- }
-
- return (k == 7);
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private bool Bench()
- {
- Initialize();
-
- for (int i = 0; i < Iterations; ++i)
- {
- s_pctr = 0;
- PermuteArray(7);
- }
-
- bool result = Validate();
-
- return result;
- }
-
- [Benchmark]
- public static void Test()
- {
- Permutate P = new Permutate();
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- P.Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- Permutate P = new Permutate();
- bool result = P.Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Permutate.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class Pi
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 100;
-#endif
-
- static int[] ComputePi(int[] a) {
-
- int d = 4;
- int r = 10000;
- int n = 251;
- int m = (int)(3.322 * n * d);
- int[] digits = new int[n];
- int i, k, q;
-
- for (i = 0; i <= m; i++) {
- a[i] = 2;
- }
-
- a[m] = 4;
-
- for (i = 1; i <= n; i++) {
- q = 0;
- for (k = m; k > 0L; k--) {
- a[k] = a[k] * r + q;
- q = a[k] / (2 * k + 1);
- a[k] -= (2 * k + 1) * q;
- q *= k;
- }
- a[0] = a[0] * r + q;
- q = a[0] / r;
- a[0] -= q * r;
- digits[i-1] = q;
- }
-
- return digits;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench(int[] a) {
- int[] digits = ComputePi(a);
- return (digits[0] == 3 && digits[1] == 1415 && digits[2] == 9265 && digits[250] == 1989);
- }
-
- [Benchmark]
- public static void Test() {
- int[] a = new int[3340];
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench(a);
- }
- }
- }
- }
-
- static bool TestBase() {
- bool result = true;
- int[] a = new int[3340];
- for (int i = 0; i < Iterations; i++) {
- result &= Bench(a);
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Pi.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public class Puzzle
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 400;
-#endif
-
- private const int PuzzleSize = 511;
- private const int ClassMax = 3;
- private const int TypeMax = 12;
- private const int D = 8;
-
- private int[] _pieceCount = new int[ClassMax + 1];
- private int[] _class = new int[TypeMax + 1];
- private int[] _pieceMax = new int[TypeMax + 1];
- private bool[] _puzzle = new bool[PuzzleSize + 1];
- private bool[][] _p;
- private int _count;
-
- private static T[][] AllocArray<T>(int n1, int n2)
- {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i)
- {
- a[i] = new T[n2];
- }
-
- return a;
- }
-
- private bool Fit(int i, int j)
- {
- for (int k = 0; k <= _pieceMax[i]; k++)
- {
- if (_p[i][k])
- {
- if (_puzzle[j + k])
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
- private int Place(int i, int j)
- {
- int k;
- for (k = 0; k <= _pieceMax[i]; k++)
- {
- if (_p[i][k])
- {
- _puzzle[j + k] = true;
- }
- }
-
- _pieceCount[_class[i]] = _pieceCount[_class[i]] - 1;
-
- for (k = j; k <= PuzzleSize; k++)
- {
- if (!_puzzle[k])
- {
- return k;
- }
- }
-
- return 0;
- }
-
- private void RemoveLocal(int i, int j)
- {
- for (int k = 0; k <= _pieceMax[i]; k++)
- {
- if (_p[i][k])
- {
- _puzzle[j + k] = false;
- }
- }
-
- _pieceCount[_class[i]] = _pieceCount[_class[i]] + 1;
- }
-
- private bool Trial(int j)
- {
- for (int i = 0; i <= TypeMax; i++)
- {
- if (_pieceCount[_class[i]] != 0)
- {
- if (Fit(i, j))
- {
- int k = Place(i, j);
- if (Trial(k) || (k == 0))
- {
- _count = _count + 1;
- return true;
- }
- else
- {
- RemoveLocal(i, j);
- }
- }
- }
- }
-
- _count = _count + 1;
- return false;
- }
-
- private bool DoIt()
- {
- int i, j, k, m, n;
-
- for (m = 0; m <= PuzzleSize; m++)
- {
- _puzzle[m] = true;
- }
-
- for (i = 1; i <= 5; i++)
- {
- for (j = 1; j <= 5; j++)
- {
- for (k = 1; k <= 5; k++)
- {
- _puzzle[i + D * (j + D * k)] = false;
- }
- }
- }
-
- for (i = 0; i <= TypeMax; i++)
- {
- for (m = 0; m <= PuzzleSize; m++)
- {
- _p[i][m] = false;
- }
- }
-
- for (i = 0; i <= 3; i++)
- {
- for (j = 0; j <= 1; j++)
- {
- for (k = 0; k <= 0; k++)
- {
- _p[0][i + D * (j + D * k)] = true;
- }
- }
- }
-
- _class[0] = 0;
- _pieceMax[0] = 3 + D * 1 + D * D * 0;
-
- for (i = 0; i <= 1; i++)
- {
- for (j = 0; j <= 0; j++)
- {
- for (k = 0; k <= 3; k++)
- {
- _p[1][i + D * (j + D * k)] = true;
- }
- }
- }
-
- _class[1] = 0;
- _pieceMax[1] = 1 + D * 0 + D * D * 3;
-
- for (i = 0; i <= 0; i++)
- {
- for (j = 0; j <= 3; j++)
- {
- for (k = 0; k <= 1; k++)
- {
- _p[2][i + D * (j + D * k)] = true;
- }
- }
- }
- _class[2] = 0;
- _pieceMax[2] = 0 + D * 3 + D * D * 1;
-
- for (i = 0; i <= 1; i++)
- {
- for (j = 0; j <= 3; j++)
- {
- for (k = 0; k <= 0; k++)
- {
- _p[3][i + D * (j + D * k)] = true;
- }
- }
- }
-
- _class[3] = 0;
- _pieceMax[3] = 1 + D * 3 + D * D * 0;
-
- for (i = 0; i <= 3; i++)
- {
- for (j = 0; j <= 0; j++)
- {
- for (k = 0; k <= 1; k++)
- {
- _p[4][i + D * (j + D * k)] = true;
- }
- }
- }
-
- _class[4] = 0;
- _pieceMax[4] = 3 + D * 0 + D * D * 1;
-
- for (i = 0; i <= 0; i++)
- {
- for (j = 0; j <= 1; j++)
- {
- for (k = 0; k <= 3; k++)
- {
- _p[5][i + D * (j + D * k)] = true;
- }
- }
- }
-
- _class[5] = 0;
- _pieceMax[5] = 0 + D * 1 + D * D * 3;
-
- for (i = 0; i <= 2; i++)
- {
- for (j = 0; j <= 0; j++)
- {
- for (k = 0; k <= 0; k++)
- {
- _p[6][i + D * (j + D * k)] = true;
- }
- }
- }
-
- _class[6] = 1;
- _pieceMax[6] = 2 + D * 0 + D * D * 0;
-
- for (i = 0; i <= 0; i++)
- {
- for (j = 0; j <= 2; j++)
- {
- for (k = 0; k <= 0; k++)
- {
- _p[7][i + D * (j + D * k)] = true;
- }
- }
- }
-
- _class[7] = 1;
- _pieceMax[7] = 0 + D * 2 + D * D * 0;
-
- for (i = 0; i <= 0; i++)
- {
- for (j = 0; j <= 0; j++)
- {
- for (k = 0; k <= 2; k++)
- {
- _p[8][i + D * (j + D * k)] = true;
- }
- }
- }
-
- _class[8] = 1;
- _pieceMax[8] = 0 + D * 0 + D * D * 2;
-
- for (i = 0; i <= 1; i++)
- {
- for (j = 0; j <= 1; j++)
- {
- for (k = 0; k <= 0; k++)
- {
- _p[9][i + D * (j + D * k)] = true;
- }
- }
- }
- _class[9] = 2;
- _pieceMax[9] = 1 + D * 1 + D * D * 0;
-
- for (i = 0; i <= 1; i++)
- {
- for (j = 0; j <= 0; j++)
- {
- for (k = 0; k <= 1; k++)
- {
- _p[10][i + D * (j + D * k)] = true;
- }
- }
- }
-
- _class[10] = 2;
- _pieceMax[10] = 1 + D * 0 + D * D * 1;
-
- for (i = 0; i <= 0; i++)
- {
- for (j = 0; j <= 1; j++)
- {
- for (k = 0; k <= 1; k++)
- {
- _p[11][i + D * (j + D * k)] = true;
- }
- }
- }
-
- _class[11] = 2;
- _pieceMax[11] = 0 + D * 1 + D * D * 1;
-
- for (i = 0; i <= 1; i++)
- {
- for (j = 0; j <= 1; j++)
- {
- for (k = 0; k <= 1; k++)
- {
- _p[12][i + D * (j + D * k)] = true;
- }
- }
- }
-
- _class[12] = 3;
- _pieceMax[12] = 1 + D * 1 + D * D * 1;
- _pieceCount[0] = 13;
- _pieceCount[1] = 3;
- _pieceCount[2] = 1;
- _pieceCount[3] = 1;
- m = 1 + D * (1 + D * 1);
- _count = 0;
-
- bool result = true;
-
- if (Fit(0, m))
- {
- n = Place(0, m);
- result = Trial(n);
- }
- else
- {
- result = false;
- }
-
- return result;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private bool Bench()
- {
- _p = AllocArray<bool>(TypeMax + 1, PuzzleSize + 1);
-
- bool result = true;
-
- for (int i = 0; i < Iterations; ++i)
- {
- result &= DoIt();
- }
-
- return result;
- }
-
- [Benchmark]
- public static void Test()
- {
- Puzzle P = new Puzzle();
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- P.Bench();
- }
- }
- }
-
- private static bool TestBase()
- {
- Puzzle P = new Puzzle();
- bool result = P.Bench();
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Puzzle.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class QuickSort
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 80000;
-#endif
-
- const int MAXNUM = 200;
- const int MODULUS = 0x20000;
- const int C = 13849;
- const int A = 25173;
- static int s_seed = 7;
-
- static int Random(int size) {
- unchecked {
- s_seed = s_seed * A + C;
- }
- return (s_seed % size);
- }
-
- static void Quick(int lo, int hi, int[] arr) {
-
- int i, j;
- int pivot, temp;
-
- if (lo < hi) {
- for (i = lo, j = hi, pivot = arr[hi]; i < j;) {
- while (i < j && arr[i] <= pivot){
- ++i;
- }
- while (j > i && arr[j] >= pivot) {
- --j;
- }
- if (i < j) {
- temp = arr[i];
- arr[i] = arr[j];
- arr[j] = temp;
- }
- }
-
- // need to swap the pivot and a[i](or a[j] as i==j) so
- // that the pivot will be at its final place in the sorted array
-
- if (i != hi) {
- temp = arr[i];
- arr[i] = pivot;
- arr[hi] = temp;
- }
- Quick(lo, i - 1, arr);
- Quick(i + 1, hi, arr);
- }
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
-
- int[] buffer = new int[MAXNUM];
-
- for (int j = 0; j < MAXNUM; ++j) {
- int temp = Random(MODULUS);
- if (temp < 0){
- temp = (-temp);
- }
- buffer[j] = temp;
- }
-
- Quick(0, MAXNUM - 1, buffer);
-
- for (int j = 0; j < MAXNUM - 1; ++j) {
- if (buffer[j] > buffer[j+1]) {
- return false;
- }
- }
-
- return true;
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench();
- }
- }
- }
- }
-
- static bool TestBase() {
- bool result = true;
- for (int i = 0; i < Iterations; i++) {
- result &= Bench();
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="QuickSort.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public class TreeInsert
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 15000;
-#endif
-
- private struct Node
- {
- public int A;
- public int L;
- public int R;
- }
-
- private struct Tree
- {
- public int Root;
- public int NextAvail;
- public Node[] Nodes;
- }
-
- private Tree _s;
-
- public TreeInsert()
- {
- _s.Nodes = new Node[10001];
- }
-
- private void BenchInner(int x)
- {
- /* a tree insertion routine from knuth */
- int i = _s.Root;
- int j = _s.NextAvail;
-
- L10:
- /* compare */
- if (_s.Nodes[i].A < x)
- {
- if (_s.Nodes[i].L != 0)
- {
- i = _s.Nodes[i].L;
- goto L10;
- }
- else
- {
- _s.Nodes[i].L = j;
- goto L20;
- }
- }
- else
- {
- if (_s.Nodes[i].R != 0)
- {
- i = _s.Nodes[i].R;
- goto L10;
- }
- else
- {
- _s.Nodes[i].R = j;
- goto L20;
- }
- }
-
- L20:
- /* insert */
- _s.Nodes[j].A = x;
- _s.Nodes[j].L = 0;
- _s.Nodes[j].R = 0;
- _s.NextAvail = j + 1;
- }
-
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private bool Bench()
- {
- _s.Root = 1;
- _s.NextAvail = 2;
- _s.Nodes[1].A = 300;
- _s.Nodes[1].L = 0;
- _s.Nodes[1].R = 0;
-
- int j = 99999;
- for (int i = 1; i <= 900; i++)
- {
- BenchInner(j & 4095);
- j = j + 33333;
- }
-
- return (_s.Nodes[500].A == 441);
- }
-
- [Benchmark]
- public static void Test()
- {
- TreeInsert T = new TreeInsert();
- foreach (var iteration in Benchmark.Iterations)
- {
- using (iteration.StartMeasurement())
- {
- for (int i = 1; i <= Iterations; i++)
- {
- T.Bench();
- }
- }
- }
- }
-
- private static bool TestBase()
- {
- TreeInsert T = new TreeInsert();
- bool result = true;
- for (int i = 1; i <= Iterations; i++)
- {
- result &= T.Bench();
- }
- return result;
- }
-
- public static int Main()
- {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="TreeInsert.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class TreeSort
-{
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 1200;
-#endif
-
- const int SortElements = 5000;
- const int Modulus = 65536;
-
- sealed class Node
- {
- public Node Left;
- public Node Right;
- public int Val;
- public Node(int n)
- {
- Left = null;
- Right = null;
- Val = n;
- }
- }
-
- static int s_biggest;
- static int s_littlest;
- static int s_seed;
-
- static void InitRand() {
- s_seed = 33;
- }
-
- static int Rand(ref int seed) {
- int multiplier = 25173;
- int increment = 13849;
- seed = (multiplier * seed + increment) % Modulus;
- return seed;
- }
-
- static void InitArray(int[] sortList) {
- InitRand();
- s_biggest = 0;
- s_littlest = Modulus;
- for (int i = 1; i <= SortElements; i++) {
- sortList[i] = Rand(ref s_seed) - 1;
- if (sortList[i] > s_biggest) {
- s_biggest = sortList[i];
- }
- else if (sortList[i] < s_littlest) {
- s_littlest = sortList[i];
- }
- }
- }
-
- static void Insert(int n, Node t) {
- if (n > t.Val) {
- if (t.Left == null) {
- t.Left = new Node(n);
- }
- else {
- Insert(n, t.Left);
- }
- }
- else if (n < t.Val) {
- if (t.Right == null) {
- t.Right = new Node(n);
- }
- else {
- Insert(n, t.Right);
- }
- }
- }
-
- static bool CheckTree(Node p) {
- bool result = true;
- if (p.Left != null) {
- if (p.Left.Val <= p.Val) {
- result = false;
- }
- else {
- result &= CheckTree(p.Left);
- }
- }
-
- if (p.Right != null) {
- if (p.Right.Val >= p.Val) {
- result = false;
- }
- else {
- result &= CheckTree(p.Right);
- }
- }
-
- return result;
- }
-
- static bool Trees(int[] sortList) {
- InitArray(sortList);
- Node tree = new Node(sortList[1]);
- for (int i = 2; i <= SortElements; i++) {
- Insert(sortList[i], tree);
- }
- bool result = CheckTree(tree);
- return result;
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench() {
- int[] sortList = new int[SortElements + 1];
- bool result = Trees(sortList);
- return result;
- }
-
- [Benchmark]
- public static void Test() {
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench();
- }
- }
- }
- }
-
- static bool TestBase() {
- bool result = true;
- for (int i = 0; i < Iterations; i++) {
- result &= Bench();
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="TreeSort.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using Microsoft.Xunit.Performance;
-using System;
-using System.Runtime.CompilerServices;
-using Xunit;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace Benchstone.BenchI
-{
-public static class XposMatrix
-{
- public const int ArraySize = 100;
-
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 25000;
-#endif
-
- static T[][] AllocArray<T>(int n1, int n2) {
- T[][] a = new T[n1][];
- for (int i = 0; i < n1; ++i) {
- a[i] = new T[n2];
- }
- return a;
- }
-
- static void Inner(int[][] x, int n) {
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= n; j++) {
- int t = x[i][j];
- x[i][j] = x[j][i];
- x[j][i] = t;
- }
- }
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- static bool Bench(int[][] matrix) {
-
- int n = ArraySize;
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= n; j++) {
- matrix[i][j] = 1;
- }
- }
-
- if (matrix[n][n] != 1) {
- return false;
- }
-
- Inner(matrix, n);
-
- if (matrix[n][n] != 1) {
- return false;
- }
-
- return true;
- }
-
- [Benchmark]
- public static void Test() {
- int[][] matrix = AllocArray<int>(ArraySize + 1, ArraySize + 1);
- foreach (var iteration in Benchmark.Iterations) {
- using (iteration.StartMeasurement()) {
- for (int i = 0; i < Iterations; i++) {
- Bench(matrix);
- }
- }
- }
- }
-
- static bool TestBase() {
- int[][] matrix = AllocArray<int>(ArraySize + 1, ArraySize + 1);
- bool result = true;
- for (int i = 0; i < Iterations; i++) {
- result &= Bench(matrix);
- }
- return result;
- }
-
- public static int Main() {
- bool result = TestBase();
- return (result ? 100 : -1);
- }
-}
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
- <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <PropertyGroup>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="XposMatrix.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
- <PropertyGroup>
- <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
- </PropertyGroup>
-</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// The Adams-Moulton Predictor Corrector Method adapted from Conte and de Boor
+// original source: adams_d.c
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Diagnostics;
+#if XUNIT_PERF
+using Xunit;
+using Microsoft.Xunit.Performance;
+#endif // XUNIT_PERF
+
+#if XUNIT_PERF
+[assembly: OptimizeForBenchmarks]
+#endif // XUNIT_PERF
+
+namespace Benchstone.BenchF
+{
+public static class Adams
+{
+#if DEBUG
+ public static int Iterations = 1;
+#else
+ public static int Iterations = 200000;
+#endif // DEBUG
+
+ static double g_xn, g_yn, g_dn, g_en;
+ const double g_xn_base = 0.09999999E+01;
+ const double g_yn_base = 0.71828180E+00;
+ const double g_dn_base = 0.21287372E-08;
+ const double g_en_base = 0.74505806E-08;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static void Bench()
+ {
+ double[] f = new double[5];
+ double xn, yn, dn, en, yxn, h, fnp, ynp, y0, x0, nz;
+ int i, k, n, nstep;
+
+#if VERBOSE
+ Console.WriteLine(" ADAMS-MOULTON METHOD ");
+#endif // VERBOSE
+
+ n = 4;
+ h = 1.0 / 32.0;
+ nstep = 32;
+ y0 = 0.0;
+ x0 = 0.0;
+ xn = 0.0;
+ yn = 0.0;
+ dn = 0.0;
+ en = 0.0;
+ nz = 0;
+
+ f[1] = x0 + y0;
+#if VERBOSE
+ Console.WriteLine("{0}, {1}, {2}, {3}, {4}", nz, x0, y0, dn, en);
+#endif // VERBOSE
+ xn = x0;
+ for (i = 2; i <= 4; i++)
+ {
+ k = i - 1;
+ xn = xn + h;
+ yn = Soln(xn);
+ f[i] = xn + yn;
+#if VERBOSE
+ Console.WriteLine("{0}, {1}, {2}, {3}, {4}", k, xn, yn, dn, en);
+#endif // VERBOSE
+ }
+
+ for (k = 4; k <= nstep; k++)
+ {
+ ynp = yn + (h / 24) * (55 * f[n] - 59 * f[n - 1] + 37 * f[n - 2] - 9 * f[n - 3]);
+ xn = xn + h;
+ fnp = xn + ynp;
+ yn = yn + (h / 24) * (9 * fnp + 19 * f[n] - 5 * f[n - 1] + f[n - 2]);
+ dn = (yn - ynp) / 14;
+ f[n - 3] = f[n - 2];
+ f[n - 2] = f[n - 1];
+ f[n - 1] = f[n];
+ f[n] = xn + yn;
+ yxn = Soln(xn);
+ en = yn - yxn;
+#if VERBOSE
+ Console.WriteLine("{0}, {1}, {2}, {3}, {4}", k, xn, yn, dn, en);
+#endif // VERBOSE
+ }
+
+ // Escape calculated values:
+ g_xn = xn;
+ g_yn = yn;
+ g_dn = dn;
+ g_en = en;
+ }
+
+ private static double Soln(double x)
+ {
+ return (System.Math.Exp(x) - 1.0 - (x));
+ }
+
+ [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
+ private static void TestBench()
+ {
+ for (int l = 1; l <= Iterations; l++)
+ {
+ Bench();
+ }
+ }
+
+#if XUNIT_PERF
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ TestBench();
+ }
+ }
+ }
+#endif // XUNIT_PERF
+
+ [MethodImpl(MethodImplOptions.NoOptimization)]
+ public static int Main(string[] argv)
+ {
+ if (argv.Length > 0)
+ {
+ Iterations = Int32.Parse(argv[0]);
+ }
+
+ Stopwatch sw = Stopwatch.StartNew();
+ TestBench();
+ sw.Stop();
+
+ bool result = true;
+ // Note: we can't check xn or yn better because of the precision
+ // with which original results are given
+ result &= System.Math.Abs(g_xn_base - g_xn) <= 1.5e-7;
+ result &= System.Math.Abs(g_yn_base - g_yn) <= 1.5e-7;
+ result &= System.Math.Abs(g_dn) <= 2.5e-9;
+ // Actual error is much bigger than base error;
+ // this is likely due to the fact that the original program was written in Fortran
+ // and was running on a mainframe with a non-IEEE floating point arithmetic
+ // (it's still beyond the published precision of yn)
+ result &= System.Math.Abs(g_en) <= 5.5e-8;
+ Console.WriteLine(result ? "Passed" : "Failed");
+
+ Console.WriteLine(" BASE.....P1 1/4 (ADAMS-MOULTON), XN = {0}", g_xn_base);
+ Console.WriteLine(" VERIFY...P1 1/4 (ADAMS-MOULTON), XN = {0}\n", g_xn);
+ Console.WriteLine(" BASE.....P1 2/4 (ADAMS-MOULTON), YN = {0}", g_yn_base);
+ Console.WriteLine(" VERIFY...P1 2/4 (ADAMS-MOULTON), YN = {0}\n", g_yn);
+ Console.WriteLine(" BASE.....P1 3/4 (ADAMS-MOULTON), DN = {0}", g_dn_base);
+ Console.WriteLine(" VERIFY...P1 3/4 (ADAMS-MOULTON), DN = {0}\n", g_dn);
+ Console.WriteLine(" BASE.....P1 4/4 (ADAMS-MOULTON), EN = {0}", g_en_base);
+ Console.WriteLine(" VERIFY...P1 4/4 (ADAMS-MOULTON), EN = {0}\n", g_en);
+
+ Console.WriteLine("Test iterations: {0}; Total time: {1} sec", Iterations, sw.Elapsed.TotalSeconds);
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Adams.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class BenchMk2
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 4000000;
+#endif
+
+ private static int s_i, s_n;
+ private static double s_p, s_a, s_x, s_f, s_e;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ s_p = Math.Acos(-1.0);
+ s_a = 0.0;
+ s_n = Iterations;
+ s_f = s_p / s_n;
+ for (s_i = 1; s_i <= s_n; ++s_i)
+ {
+ s_f = s_p / s_n;
+ s_x = s_f * s_i;
+ s_e = Math.Abs(Math.Log(Math.Exp(s_x)) / s_x) - Math.Sqrt((Math.Sin(s_x) * Math.Sin(s_x)) + Math.Cos(s_x) * Math.Cos(s_x));
+ s_a = s_a + Math.Abs(s_e);
+ }
+
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="BenchMk2.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class BenchMrk
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 4000000;
+#endif
+
+ private static int s_i, s_n;
+ private static float s_p, s_a, s_x, s_f, s_e;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ s_p = (float)Math.Acos(-1.0);
+ s_a = 0.0F;
+ s_n = Iterations;
+ s_f = s_p / s_n;
+ for (s_i = 1; s_i <= s_n; ++s_i)
+ {
+ s_f = s_p / s_n;
+ s_x = s_f * s_i;
+ s_e = (float)(Math.Abs(Math.Log(Math.Exp(s_x)) / s_x) - Math.Sqrt((Math.Sin(s_x) * Math.Sin(s_x)) + Math.Cos(s_x) * Math.Cos(s_x)));
+ s_a = s_a + Math.Abs(s_e);
+ }
+
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="BenchMrk.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// The Bisect algorithm adapted from Conte and de Boor
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class Bisect
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 400000;
+#endif
+
+ public static volatile object VolatileObject;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static void Escape(object obj)
+ {
+ VolatileObject = obj;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ int idbg, iflag;
+ double a, b, error, p1, xi;
+
+ iflag = 0;
+ error = 0.0;
+ xi = 0.0;
+ idbg = 0;
+ for (int i = 1; i <= Iterations; i++)
+ {
+ for (int j = 1; j <= 10; j++)
+ {
+ a = 1.0;
+ b = 2.0;
+ p1 = 0.000001;
+ Inner(ref a, ref b, ref p1, out iflag);
+ if (iflag > 1)
+ {
+ goto L999;
+ }
+
+ xi = (a + b) / 2.0;
+ if (a > b)
+ {
+ error = (a - b) / 2.0;
+ }
+ else
+ {
+ error = (b - a) / 2.0;
+ }
+
+ if (idbg != 0)
+ {
+ System.Console.WriteLine(" the root is {0:E} plus/minus {1:E}\n", xi, error);
+ }
+ }
+ }
+ L999:
+ {
+ }
+
+ // Escape iflag, error, xi so that they appear live
+ Escape(iflag);
+ Escape(error);
+ Escape(xi);
+
+ return true;
+ }
+
+ private static double FF(double x)
+ {
+ return ((-1.0 - (x * (1.0 - (x * x)))));
+ }
+
+ private static void Inner(ref double a, ref double b, ref double xtol, out int iflag)
+ {
+ double fa, error;
+ double xm, fm;
+
+ iflag = 0;
+ fa = FF(a);
+ /* check for sign change */
+ if (((fa) * FF(b)) < 0.0)
+ {
+ goto L5;
+ }
+
+ iflag = 2;
+ goto L99;
+
+ L5:
+ {
+ error = System.Math.Abs(b - a);
+ }
+ L6:
+ error = error / 2.0;
+ /* check for sufficiently small interval */
+ if (error < xtol)
+ {
+ goto L99;
+ }
+ xm = (a + b) / 2.0;
+ /* check for unreasonable error requirement */
+ if (xm + error == xm)
+ {
+ goto L20;
+ }
+
+ fm = FF(xm);
+ /* change to new interval */
+ if (fa * fm < 0.0)
+ {
+ goto L9;
+ }
+ a = xm;
+ fa = fm;
+ goto L6;
+ L9:
+ b = xm;
+ goto L6;
+ L20:
+ iflag = 1;
+ L99:
+ {
+ }
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Bisect.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class DMath
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 100000;
+#endif
+
+ private const double Deg2Rad = 57.29577951;
+ private static volatile object s_volatileObject;
+
+ private static void Escape(object obj)
+ {
+ s_volatileObject = obj;
+ }
+
+ private static double Fact(double n)
+ {
+ double res;
+ res = 1.0;
+ while (n > 0.0)
+ {
+ res *= n;
+ n -= 1.0;
+ }
+
+ return res;
+ }
+
+ private static double Power(double n, double p)
+ {
+ double res;
+ res = 1.0;
+ while (p > 0.0)
+ {
+ res *= n;
+ p -= 1.0;
+ }
+
+ return res;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench(int loop)
+ {
+ double[] sines = new double[91];
+ double angle, radians, sine, worksine, temp, k;
+ double diff;
+
+ for (int iter = 1; iter <= loop; iter++)
+ {
+ for (angle = 0.0; angle <= 90.0; angle += 1.0)
+ {
+ radians = angle / Deg2Rad;
+ k = 0.0;
+ worksine = 0.0;
+ do
+ {
+ sine = worksine;
+ temp = (2.0 * k) + 1.0;
+ worksine += (Power(-1.0, k) / Fact(temp)) * Power(radians, temp);
+ k += 1.0;
+ diff = Math.Abs(sine - worksine);
+ } while (diff > 1E-8);
+
+ sines[(int)angle] = worksine;
+ }
+ }
+
+ // Escape sines array so that its elements appear live-out
+ Escape(sines);
+
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench(Iterations);
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench(Iterations);
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="DMath.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// FFT benchmark adapted from a Fortran routine from the book
+// Digital Signal Analysis, Samuel Stearns, Hayden Book Co.
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class FFT
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 300000;
+#endif
+
+ private static readonly int s_points = 16;
+ public static volatile object VolatileObject;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static void Escape(object obj)
+ {
+ VolatileObject = obj;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ double[] fr = new double[17];
+ double[] fi = new double[17];
+
+ int i;
+ double t;
+
+ for (int iter = 1; iter <= Iterations; iter++)
+ {
+ for (i = 1; i <= s_points; ++i)
+ {
+ t = ((double)0.375) * ((double)(i - 1));
+ fr[i] = System.Math.Exp(-t) * System.Math.Sin(t);
+ fi[i] = 0.0;
+ }
+ FastFourierT(fr, fi, s_points);
+ }
+
+ // Escape the results to live-out.
+ Escape(fr);
+ Escape(fi);
+
+ return true;
+ }
+
+ private static void FastFourierT(double[] fr, double[] fi, int n)
+ {
+ int i, j, l, m;
+ int istep, mr, nn;
+ double a, el, tr, ti, wr, wi;
+
+ mr = 0;
+ nn = n - 1;
+ m = 1;
+
+ do
+ {
+ l = n;
+ for (l = l / 2; ((mr + l) > nn); l = l / 2)
+ {
+ }
+ // l <= n/2
+ // mr <= (mr % l) + l ==> mr <= (l - 1) + l = 2l - 1
+ // ==> mr <= n - 1
+ mr = (mr % l) + l;
+
+ if (mr > m)
+ {
+ // Accessing upto m + 1 ==> nn + 1 ==> n - 1 + 1 ==> n
+ tr = fr[m + 1];
+ // Accessing upto mr + 1 ==> n - 1 + 1 ==> n
+ fr[m + 1] = fr[mr + 1];
+ fr[mr + 1] = tr;
+ ti = fi[m + 1];
+ fi[m + 1] = fi[mr + 1];
+ fi[mr + 1] = ti;
+ }
+ ++m;
+ } while (m <= nn);
+
+ for (l = 1; l < n; l = istep)
+ {
+ istep = 2 * l;
+
+ el = ((double)l);
+ m = 1;
+ do
+ {
+ a = ((double)3.1415926535) * (((double)(1 - m)) / el);
+ wr = System.Math.Cos(a);
+ wi = System.Math.Sin(a);
+ i = m;
+ do
+ {
+ // l can have a maximum value of 2^x where 2^x < n and 2^(x+1) = n, since n is even
+ // ==> istep <= 2^(x+1) ==> i can only take the value of m and m <= l
+ // Therefore, j <= l + l
+ // or j <= 2^x + 2^x = 2^(x+1) = n
+ // i.e. j <= n
+ j = i + l;
+
+ // Accessing upto j <= n, i <= n
+ tr = wr * fr[j] - wi * fi[j];
+ ti = wr * fi[j] + wi * fr[j];
+ fr[j] = fr[i] - tr;
+ fi[j] = fi[i] - ti;
+ fr[i] = fr[i] + tr;
+ fi[i] = fi[i] + ti;
+ i += istep;
+ } while (i <= n);
+ ++m;
+ } while (m <= l);
+ }
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="FFT.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class InProd
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 70;
+#endif
+
+ private const int RowSize = 10 * Iterations;
+
+ private static int s_seed;
+
+ private static T[][] AllocArray<T>(int n1, int n2)
+ {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i)
+ {
+ a[i] = new T[n2];
+ }
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ double[][] rma = AllocArray<double>(RowSize, RowSize);
+ double[][] rmb = AllocArray<double>(RowSize, RowSize);
+ double[][] rmr = AllocArray<double>(RowSize, RowSize);
+
+ double sum;
+
+ Inner(rma, rmb, rmr);
+
+ for (int i = 1; i < RowSize; i++)
+ {
+ for (int j = 1; j < RowSize; j++)
+ {
+ sum = 0;
+ for (int k = 1; k < RowSize; k++)
+ {
+ sum = sum + rma[i][k] * rmb[k][j];
+ }
+ if (rmr[i][j] != sum)
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private static void InitRand()
+ {
+ s_seed = 7774755;
+ }
+
+ private static int Rand()
+ {
+ s_seed = (s_seed * 77 + 13218009) % 3687091;
+ return s_seed;
+ }
+
+ private static void InitMatrix(double[][] m)
+ {
+ for (int i = 1; i < RowSize; i++)
+ {
+ for (int j = 1; j < RowSize; j++)
+ {
+ m[i][j] = (Rand() % 120 - 60) / 3;
+ }
+ }
+ }
+
+ private static void InnerProduct(out double result, double[][] a, double[][] b, int row, int col)
+ {
+ result = 0.0;
+ for (int i = 1; i < RowSize; i++)
+ {
+ result = result + a[row][i] * b[i][col];
+ }
+ }
+
+ private static void Inner(double[][] rma, double[][] rmb, double[][] rmr)
+ {
+ InitRand();
+ InitMatrix(rma);
+ InitMatrix(rmb);
+ for (int i = 1; i < RowSize; i++)
+ {
+ for (int j = 1; j < RowSize; j++)
+ {
+ InnerProduct(out rmr[i][j], rma, rmb, i, j);
+ }
+ }
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="InProd.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// Solution of linear algebraic equations and matrix inversion.
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class InvMt
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 80;
+#endif
+
+ private const int MatSize = Iterations;
+
+ private static T[][] AllocArray<T>(int n1, int n2)
+ {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i)
+ {
+ a[i] = new T[n2];
+ }
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ double[][] t = AllocArray<double>(MatSize + 1, (MatSize + 1) * 2);
+
+ double det, detinv, ber, p;
+ int n, i, j;
+
+ n = MatSize;
+ for (i = 1; i <= n; i++)
+ {
+ for (j = 1; j <= n; j++)
+ {
+ if (i == j)
+ {
+ t[i][j] = 2.0001;
+ t[i][n + 1 + j] = 1.0;
+ }
+ else
+ {
+ t[i][j] = 1.0001;
+ t[i][n + 1 + j] = 0.0;
+ }
+ }
+ t[i][n + 1] = System.Math.Sqrt((float)i);
+ }
+
+ Inner(t, out det, ref n);
+
+ for (i = 1; i <= n; i++)
+ {
+ for (j = 1; j <= n; j++)
+ {
+ p = t[i][j];
+ t[i][j] = t[i][n + 1 + j];
+ t[i][n + 1 + j] = p;
+ }
+ }
+
+ Inner(t, out detinv, ref n);
+
+ ber = 0.0;
+ for (i = 1; i <= n; i++)
+ {
+ ber = ber + System.Math.Abs(System.Math.Sqrt((double)i) - t[i][n + 1]);
+ }
+
+ return true;
+ }
+
+ private static void Inner(double[][] t, out double det, ref int n)
+ {
+ double tik, tkk;
+
+ det = 1.0;
+ for (int k = 1; k <= n; k++)
+ {
+ tkk = t[k][k];
+ det = det * tkk;
+
+ for (int j = 1; j <= (2 * n + 1); j++)
+ {
+ t[k][j] = t[k][j] / tkk;
+ }
+
+ for (int i = 1; i <= n; i++)
+ {
+ if (i != k)
+ {
+ tik = t[i][k];
+ for (int j = 1; j <= (2 * n + 1); j++)
+ {
+ t[i][j] = t[i][j] - t[k][j] * tik;
+ }
+ }
+ }
+ }
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="InvMt.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// C# adaptation of C implementation of Livermore Loops Fortran benchmark.
+
+/* Livermore Loops coded in C Latest File Modification 20 Oct 92,
+ * by Tim Peters, Kendall Square Res. Corp. tim@ksr.com, ksr!tim@uunet.uu.net
+ * SUBROUTINE KERNEL( TK) replaces the Fortran routine in LFK Test program.
+ ************************************************************************
+ * *
+ * KERNEL executes 24 samples of "C" computation *
+ * *
+ * TK(1) - total cpu time to execute only the 24 kernels.*
+ * TK(2) - total Flops executed by the 24 Kernels *
+ * *
+ ************************************************************************
+ * *
+ * L. L. N. L. " C " K E R N E L S: M F L O P S *
+ * *
+ * These kernels measure " C " numerical computation *
+ * rates for a spectrum of cpu-limited computational *
+ * structures or benchmarks. Mathematical through-put *
+ * is measured in units of millions of floating-point *
+ * operations executed per second, called Megaflops/sec. *
+ * *
+ * Fonzi's Law: There is not now and there never will be a language *
+ * in which it is the least bit difficult to write *
+ * bad programs. *
+ * F.H.MCMAHON 1972 *
+ ************************************************************************
+ *Originally from Greg Astfalk, AT&T, P.O.Box 900, Princeton, NJ. 08540*
+ * by way of Frank McMahon (LLNL). *
+ * *
+ * REFERENCE *
+ * *
+ * F.H.McMahon, The Livermore Fortran Kernels: *
+ * A Computer Test Of The Numerical Performance Range, *
+ * Lawrence Livermore National Laboratory, *
+ * Livermore, California, UCRL-53745, December 1986. *
+ * *
+ * from: National Technical Information Service *
+ * U.S. Department of Commerce *
+ * 5285 Port Royal Road *
+ * Springfield, VA. 22161 *
+ * *
+ * Changes made to correct many array subscripting problems, *
+ * make more readable (added #define's), include the original *
+ * FORTRAN versions of the runs as comments, and make more *
+ * portable by Kelly O'Hair (LLNL) and Chuck Rasbold (LLNL). *
+ * *
+ ************************************************************************
+ */
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public class LLoops
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 4000;
+#endif
+
+ private const double MaxErr = 1.0e-6;
+
+ private double[] _x = new double[1002];
+ private double[] _y = new double[1002];
+ private double[] _z = new double[1002];
+ private double[] _u = new double[501];
+ private double[][] _px;
+ private double[][] _cx;
+ private double[][][] _u1;
+ private double[][][] _u2;
+ private double[][][] _u3;
+ private double[][] _b;
+ private double[] _bnk1 = new double[6];
+ private double[][] _c;
+ private double[] _bnk2 = new double[6];
+ private double[][] _p;
+ private double[] _bnk3 = new double[6];
+ private double[][] _h;
+ private double[] _bnk4 = new double[6];
+ private double[] _bnk5 = new double[6];
+ private double[] _ex = new double[68];
+ private double[] _rh = new double[68];
+ private double[] _dex = new double[68];
+ private double[] _vx = new double[151];
+ private double[] _xx = new double[151];
+ private double[] _grd = new double[151];
+ private int[] _e = new int[193];
+ private int[] _f = new int[193];
+ private int[] _nrops = { 0, 5, 10, 2, 2, 2, 2, 16, 36, 17, 9, 1, 1, 7, 11 };
+ private int[] _loops = { 0, 400, 200, 1000, 510, 1000, 1000, 120, 40, 100, 100, 1000, 1000, 128, 150 };
+ private double[] _checks = {
+ 0, 0.811986948148e+07, 0.356310000000e+03, 0.356310000000e+03, -0.402412007078e+05,
+ 0.136579037764e+06, 0.419716278716e+06,
+ 0.429449847526e+07, 0.314064400000e+06,
+ 0.182709000000e+07, -0.140415250000e+09,
+ 0.374895020500e+09, 0.000000000000e+00,
+ 0.171449024000e+06, -0.510829560800e+07
+ };
+
+ public static volatile object VolatileObject;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static void Escape(object obj)
+ {
+ VolatileObject = obj;
+ }
+
+ private static T[][] AllocArray<T>(int n1, int n2)
+ {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i)
+ {
+ a[i] = new T[n2];
+ }
+ return a;
+ }
+
+ private static T[][][] AllocArray<T>(int n1, int n2, int n3)
+ {
+ T[][][] a = new T[n1][][];
+ for (int i = 0; i < n1; ++i)
+ {
+ a[i] = new T[n2][];
+ for (int j = 0; j < n2; j++)
+ {
+ a[i][j] = new T[n3];
+ }
+ }
+
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private bool Bench()
+ {
+ _px = AllocArray<double>(16, 101);
+ _cx = AllocArray<double>(16, 101);
+
+ _u1 = AllocArray<double>(6, 23, 3);
+ _u2 = AllocArray<double>(6, 23, 3);
+ _u3 = AllocArray<double>(6, 23, 3);
+
+ _b = AllocArray<double>(65, 9);
+ _c = AllocArray<double>(65, 9);
+ _h = AllocArray<double>(65, 9);
+
+ _p = AllocArray<double>(5, 513);
+
+ for (int i = 0; i < Iterations; i++)
+ {
+ Main1(i < Iterations - 1 ? 0 : 1);
+ }
+
+ return true;
+ }
+
+ private static int Clock()
+ {
+ return 0;
+ }
+
+ private void Main1(int output)
+ {
+ int nt, lw, nl1, nl2;
+ int i, i1, i2, ip, ir, ix, j, j1, j2, k, kx, ky, l, m;
+ double[] ts = new double[21];
+ double[] rt = new double[21];
+ double[] rpm = new double[21];
+ double[] cksum = new double[21];
+ double r, t, a11, a12, a13, sig, a21, a22, a23, a31, a32, a33;
+ double b28, b27, b26, b25, b24, b23, b22, c0, flx, rx1;
+ double q, s, scale, uu, du1, du2, du3, ar, br, cr, xi, ri;
+ int[] mops = new int[20];
+
+ for (i = 1; i <= 20; i++)
+ {
+ cksum[i] = 0.0;
+ }
+
+ r = 4.86;
+ t = 276.0;
+ a11 = 0.5;
+ a12 = 0.33;
+ a13 = 0.25;
+ sig = 0.8;
+ a21 = 0.20;
+ a22 = 0.167;
+ a23 = 0.141;
+ a31 = 0.125;
+ a32 = 0.111;
+ a33 = 0.10;
+ b28 = 0.1;
+ b27 = 0.2;
+ b26 = 0.3;
+ b25 = 0.4;
+ b24 = 0.5;
+ b23 = 0.6;
+ b22 = 0.7;
+ c0 = 0.8;
+ flx = 4.689;
+ rx1 = 64.0;
+
+ /*
+ * end of initialization -- begin timing
+ */
+
+ /* loop 1 hydro excerpt */
+
+ Init();
+ ts[1] = (double)Clock();
+ q = 0.0;
+ for (k = 1; k <= 400; k++)
+ {
+ _x[k] = q + _y[k] * (r * _z[k + 10] + t * _z[k + 11]);
+ }
+ ts[1] = (double)Clock() - ts[1];
+ for (k = 1; k <= 400; k++)
+ {
+ cksum[1] += (double)k * _x[k];
+ }
+
+ /* loop 2 mlr, inner product */
+
+ Init();
+ ts[2] = (double)Clock();
+ q = 0.0;
+ for (k = 1; k <= 996; k += 5)
+ {
+ q += _z[k] * _x[k] + _z[k + 1] * _x[k + 1] + _z[k + 2] * _x[k + 2] + _z[k + 3] * _x[k + 3] + _z[k + 4] * _x[k + 4];
+ }
+ ts[2] = (double)Clock() - ts[2];
+ cksum[2] = q;
+
+ /* loop 3 inner prod */
+
+ Init();
+ ts[3] = (double)Clock();
+ q = 0.0;
+ for (k = 1; k <= 1000; k++)
+ {
+ q += _z[k] * _x[k];
+ }
+ ts[3] = (double)Clock() - ts[3];
+ cksum[3] = q;
+
+ /* loop 4 banded linear equarions */
+
+ Init();
+ ts[4] = (double)Clock();
+ for (l = 7; l <= 107; l += 50)
+ {
+ lw = l;
+ for (j = 30; j <= 870; j += 5)
+ {
+ _x[l - 1] -= _x[lw++] * _y[j];
+ }
+ _x[l - 1] = _y[5] * _x[l - 1];
+ }
+ ts[4] = (double)Clock() - ts[4];
+ for (l = 7; l <= 107; l += 50)
+ {
+ cksum[4] += (double)l * _x[l - 1];
+ }
+
+ /* loop 5 tri-diagonal elimination, below diagonal */
+
+ Init();
+ ts[5] = (double)Clock();
+ for (i = 2; i <= 998; i += 3)
+ {
+ _x[i] = _z[i] * (_y[i] - _x[i - 1]);
+ _x[i + 1] = _z[i + 1] * (_y[i + 1] - _x[i]);
+ _x[i + 2] = _z[i + 2] * (_y[i + 2] - _x[i + 1]);
+ }
+ ts[5] = (double)Clock() - ts[5];
+ for (i = 2; i <= 1000; i++)
+ {
+ cksum[5] += (double)i * _x[i];
+ }
+
+ /* loop 6 tri-diagonal elimination, above diagonal */
+
+ Init();
+ ts[6] = (double)Clock();
+ for (j = 3; j <= 999; j += 3)
+ {
+ i = 1003 - j;
+ _x[i] = _x[i] - _z[i] * _x[i + 1];
+ _x[i - 1] = _x[i - 1] - _z[i - 1] * _x[i];
+ _x[i - 2] = _x[i - 2] - _z[i - 2] * _x[i - 1];
+ }
+ ts[6] = (double)Clock() - ts[6];
+ for (j = 1; j <= 999; j++)
+ {
+ l = 1001 - j;
+ cksum[6] += (double)j * _x[l];
+ }
+
+ /* loop 7 equation of state excerpt */
+
+ Init();
+ ts[7] = (double)Clock();
+ for (m = 1; m <= 120; m++)
+ {
+ _x[m] = _u[m] + r * (_z[m] + r * _y[m]) + t * (_u[m + 3] + r * (_u[m + 2] + r * _u[m + 1]) + t * (_u[m + 6] + r * (_u[m + 5] + r * _u[m + 4])));
+ }
+ ts[7] = (double)Clock() - ts[7];
+ for (m = 1; m <= 120; m++)
+ {
+ cksum[7] += (double)m * _x[m];
+ }
+
+ /* loop 8 p.d.e. integration */
+
+ Init();
+ ts[8] = (double)Clock();
+ nl1 = 1;
+ nl2 = 2;
+ for (kx = 2; kx <= 3; kx++)
+ {
+ for (ky = 2; ky <= 21; ky++)
+ {
+ du1 = _u1[kx][ky + 1][nl1] - _u1[kx][ky - 1][nl1];
+ du2 = _u2[kx][ky + 1][nl1] - _u2[kx][ky - 1][nl1];
+ du3 = _u3[kx][ky + 1][nl1] - _u3[kx][ky - 1][nl1];
+ _u1[kx][ky][nl2] = _u1[kx][ky][nl1] + a11 * du1 + a12 * du2 + a13 * du3 + sig * (_u1[kx + 1][ky][nl1]
+ - 2.0 * _u1[kx][ky][nl1] + _u1[kx - 1][ky][nl1]);
+ _u2[kx][ky][nl2] = _u2[kx][ky][nl1] + a21 * du1 + a22 * du2 + a23 * du3 + sig * (_u2[kx + 1][ky][nl1]
+ - 2.0 * _u2[kx][ky][nl1] + _u2[kx - 1][ky][nl1]);
+ _u3[kx][ky][nl2] = _u3[kx][ky][nl1] + a31 * du1 + a32 * du2 + a33 * du3 + sig * (_u3[kx + 1][ky][nl1]
+ - 2.0 * _u3[kx][ky][nl1] + _u3[kx - 1][ky][nl1]);
+ }
+ }
+ ts[8] = (double)Clock() - ts[8];
+ for (i = 1; i <= 2; i++)
+ {
+ for (kx = 2; kx <= 3; kx++)
+ {
+ for (ky = 2; ky <= 21; ky++)
+ {
+ cksum[8] += (double)kx * (double)ky * (double)i * (_u1[kx][ky][i] + _u2[kx][ky][i] + _u3[kx][ky][i]);
+ }
+ }
+ }
+
+ /* loop 9 integrate predictors */
+
+ Init();
+ ts[9] = (double)Clock();
+ for (i = 1; i <= 100; i++)
+ {
+ _px[1][i] = b28 * _px[13][i] + b27 * _px[12][i] + b26 * _px[11][i] + b25 * _px[10][i] + b24 * _px[9][i] +
+ b23 * _px[8][i] + b22 * _px[7][i] + c0 * (_px[5][i] + _px[6][i]) + _px[3][i];
+ }
+ ts[9] = (double)Clock() - ts[9];
+ for (i = 1; i <= 100; i++)
+ {
+ cksum[9] += (double)i * _px[1][i];
+ }
+
+ /* loop 10 difference predictors */
+
+ Init();
+ ts[10] = (double)Clock();
+ for (i = 1; i <= 100; i++)
+ {
+ ar = _cx[5][i];
+ br = ar - _px[5][i];
+ _px[5][i] = ar;
+ cr = br - _px[6][i];
+ _px[6][i] = br;
+ ar = cr - _px[7][i];
+ _px[7][i] = cr;
+ br = ar - _px[8][i];
+ _px[8][i] = ar;
+ cr = br - _px[9][i];
+ _px[9][i] = br;
+ ar = cr - _px[10][i];
+ _px[10][i] = cr;
+ br = ar - _px[11][i];
+ _px[11][i] = ar;
+ cr = br - _px[12][i];
+ _px[12][i] = br;
+ _px[14][i] = cr - _px[13][i];
+ _px[13][i] = cr;
+ }
+ ts[10] = (double)Clock() - ts[10];
+ for (i = 1; i <= 100; i++)
+ {
+ for (k = 5; k <= 14; k++)
+ {
+ cksum[10] += (double)k * (double)i * _px[k][i];
+ }
+ }
+
+ /* loop 11 first sum. */
+
+ Init();
+ ts[11] = (double)Clock();
+ _x[1] = _y[1];
+ for (k = 2; k <= 1000; k++)
+ {
+ _x[k] = _x[k - 1] + _y[k];
+ }
+ ts[11] = (double)Clock() - ts[11];
+ for (k = 1; k <= 1000; k++)
+ {
+ cksum[11] += (double)k * _x[k];
+ }
+
+ /* loop 12 first diff. */
+
+ Init();
+ ts[12] = (double)Clock();
+ for (k = 1; k <= 999; k++)
+ {
+ _x[k] = _y[k + 1] - _y[k];
+ }
+ ts[12] = (double)Clock() - ts[12];
+ for (k = 1; k <= 999; k++)
+ {
+ cksum[12] += (double)k * _x[k];
+ }
+
+ /* loop 13 2-d particle pusher */
+
+ Init();
+ ts[13] = (double)Clock();
+ for (ip = 1; ip <= 128; ip++)
+ {
+ i1 = (int)_p[1][ip];
+ j1 = (int)_p[2][ip];
+ _p[3][ip] += _b[i1][j1];
+ _p[4][ip] += _c[i1][j1];
+ _p[1][ip] += _p[3][ip];
+ _p[2][ip] += _p[4][ip];
+ // Each element of m_p, m_b and m_c is initialized to 1.00025 in Init().
+ // From the assignments above,
+ // i2 = m_p[1][ip] = m_p[1][ip] + m_p[3][ip] = m_p[1][ip] + m_p[3][ip] + m_b[i1][j1] = 1 + 1 + 1 = 3
+ // j2 = m_p[2][ip] = m_p[2][ip] + m_p[4][ip] = m_p[2][ip] + m_p[4][ip] + m_c[i1][j1] = 1 + 1 + 1 = 3
+ i2 = (int)_p[1][ip];
+ j2 = (int)_p[2][ip];
+ // Accessing m_y, m_z upto 35
+ _p[1][ip] += _y[i2 + 32];
+ _p[2][ip] += _z[j2 + 32];
+
+ i2 += _e[i2 + 32];
+ j2 += _f[j2 + 32];
+ _h[i2][j2] += 1.0;
+ }
+ ts[13] = (double)Clock() - ts[13];
+ for (ip = 1; ip <= 128; ip++)
+ {
+ cksum[13] += (double)ip * (_p[3][ip] + _p[4][ip] + _p[1][ip] + _p[2][ip]);
+ }
+ for (k = 1; k <= 64; k++)
+ {
+ for (ix = 1; ix <= 8; ix++)
+ {
+ cksum[13] += (double)k * (double)ix * _h[k][ix];
+ }
+ }
+
+ /* loop 14 1-d particle pusher */
+
+ Init();
+ ts[14] = (double)Clock();
+ for (k = 1; k <= 150; k++)
+ {
+ // m_grd[150] = 13.636
+ // Therefore ix <= 13
+ ix = (int)_grd[k];
+ xi = (double)ix;
+ _vx[k] += _ex[ix] + (_xx[k] - xi) * _dex[ix];
+ _xx[k] += _vx[k] + flx;
+ ir = (int)_xx[k];
+ ri = (double)ir;
+ rx1 = _xx[k] - ri;
+ ir = System.Math.Abs(ir % 64);
+ _xx[k] = ri + rx1;
+ // ir < 64 since ir = ir % 64
+ // So m_rh is accessed upto 64
+ _rh[ir] += 1.0 - rx1;
+ _rh[ir + 1] += rx1;
+ }
+ ts[14] = (double)Clock() - ts[14];
+ for (k = 1; k <= 150; k++)
+ {
+ cksum[14] += (double)k * (_vx[k] + _xx[k]);
+ }
+ for (k = 1; k <= 67; k++)
+ {
+ cksum[14] += (double)k * _rh[k];
+ }
+
+ /* time the clock call */
+
+ ts[15] = (double)Clock();
+ ts[15] = (double)Clock() - ts[15];
+
+ /* scale= set to convert time to micro-seconds */
+
+ scale = 1.0;
+ rt[15] = ts[15] * scale;
+
+ nt = 14;
+ t = s = uu = 0.0;
+ for (k = 1; k <= nt; k++)
+ {
+ rt[k] = (ts[k] - ts[15]) * scale;
+ t += rt[k];
+ mops[k] = _nrops[k] * _loops[k];
+ s += (double)mops[k];
+ rpm[k] = 0.0;
+ if (rt[k] != 0.0)
+ {
+ rpm[k] = (double)mops[k] / rt[k];
+ }
+ uu += rpm[k];
+ }
+ uu /= (double)nt;
+ s /= t;
+
+ // Ensure that the array elements are live-out
+ Escape(ts);
+ Escape(rt);
+ Escape(rpm);
+ Escape(cksum);
+ Escape(mops);
+ }
+
+ private void Init()
+ {
+ int j, k, l;
+
+ for (k = 1; k <= 1000; k++)
+ {
+ _x[k] = 1.11;
+ _y[k] = 1.123;
+ _z[k] = 0.321;
+ }
+
+ for (k = 1; k <= 500; k++)
+ {
+ _u[k] = 0.00025;
+ }
+
+ for (k = 1; k <= 15; k++)
+ {
+ for (l = 1; l <= 100; l++)
+ {
+ _px[k][l] = l;
+ _cx[k][l] = l;
+ }
+ }
+
+ for (j = 1; j < 6; j++)
+ {
+ for (k = 1; k < 23; k++)
+ {
+ for (l = 1; l < 3; l++)
+ {
+ _u1[j][k][l] = k;
+ _u2[j][k][l] = k + k;
+ _u3[j][k][l] = k + k + k;
+ }
+ }
+ }
+
+ for (j = 1; j < 65; j++)
+ {
+ for (k = 1; k < 9; k++)
+ {
+ _b[j][k] = 1.00025;
+ _c[j][k] = 1.00025;
+ _h[j][k] = 1.00025;
+ }
+ }
+
+ for (j = 1; j < 6; j++)
+ {
+ _bnk1[j] = j * 100;
+ _bnk2[j] = j * 110;
+ _bnk3[j] = j * 120;
+ _bnk4[j] = j * 130;
+ _bnk5[j] = j * 140;
+ }
+
+ for (j = 1; j < 5; j++)
+ {
+ for (k = 1; k < 513; k++)
+ {
+ _p[j][k] = 1.00025;
+ }
+ }
+
+ for (j = 1; j < 193; j++)
+ {
+ _e[j] = _f[j] = 1;
+ }
+
+ for (j = 1; j < 68; j++)
+ {
+ _ex[j] = _rh[j] = _dex[j] = (double)j;
+ }
+
+ for (j = 1; j < 151; j++)
+ {
+ _vx[j] = 0.001;
+ _xx[j] = 0.001;
+ _grd[j] = (double)(j / 8 + 3);
+ }
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ var lloops = new LLoops();
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ lloops.Bench();
+ }
+ }
+ }
+
+ private bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ var lloops = new LLoops();
+ bool result = lloops.TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="LLoops.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+.NET Core uses third-party libraries or other resources that may be
+distributed under licenses different than the .NET Core software.
+
+In the event that we accidentally failed to list a required notice, please
+bring it to our attention. Post an issue or email us:
+
+ dotnet@microsoft.com
+
+The attached notices are provided for information only.
+
+License notice for Livermore Loops coded in C
+---------------------------------------------
+
+http://www.netlib.org/benchmark/livermorec
+
+No specific license is given, so attributing and using in "good faith"
+in the same way that it has been offered. We will delete upon request.
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// This program solves the "lorenz" equations using Runge-Kutta 4
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class Lorenz
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 8000000;
+#endif
+
+ private static double s_t = 0.0;
+ private static double s_x = 5.0;
+ private static double s_y = 2.0;
+ private static double s_z = 27.0;
+
+ private static int s_nsteps = Iterations;
+ private static double s_h = -1.0;
+ private static int s_printDerivative = -1;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ double k1, k2, k3, k4;
+ double l1, l2, l3, l4;
+ double m1, m2, m3, m4;
+ double hdiv2, hdiv6;
+ int i;
+
+ if (s_h < 0.0)
+ {
+ s_h = 20.0 / (double)s_nsteps;
+ }
+ if (s_printDerivative < 0)
+ {
+ s_printDerivative = s_nsteps;
+ }
+
+ hdiv2 = s_h / 2.0;
+ hdiv6 = s_h / 6.0;
+
+ for (i = 0; i < s_nsteps; ++i)
+ {
+ double t_arg, x_arg, y_arg, z_arg;
+
+ k1 = F(s_t, s_x, s_y, s_z);
+ l1 = G(s_t, s_x, s_y, s_z);
+ m1 = H(s_t, s_x, s_y, s_z);
+
+ t_arg = s_t + hdiv2;
+ x_arg = s_x + hdiv2 * k1;
+ y_arg = s_y + hdiv2 * l1;
+ z_arg = s_z + hdiv2 * m1;
+
+ k2 = F(t_arg, x_arg, y_arg, z_arg);
+ l2 = G(t_arg, x_arg, y_arg, z_arg);
+ m2 = H(t_arg, x_arg, y_arg, z_arg);
+
+ x_arg = s_x + hdiv2 * k2;
+ y_arg = s_y + hdiv2 * l2;
+ z_arg = s_z + hdiv2 * m2;
+
+ k3 = F(t_arg, x_arg, y_arg, z_arg);
+ l3 = G(t_arg, x_arg, y_arg, z_arg);
+ m3 = H(t_arg, x_arg, y_arg, z_arg);
+
+ t_arg = s_t + s_h;
+ x_arg = s_x + s_h * k3;
+ y_arg = s_y + s_h * l3;
+ z_arg = s_z + s_h * m3;
+
+ k4 = F(t_arg, x_arg, y_arg, z_arg);
+ l4 = G(t_arg, x_arg, y_arg, z_arg);
+ m4 = H(t_arg, x_arg, y_arg, z_arg);
+
+ s_x = s_x + hdiv6 * (k1 + 2.0 * k2 + 2.0 * k3 + k4);
+ s_y = s_y + hdiv6 * (l1 + 2.0 * l2 + 2.0 * l3 + l4);
+ s_z = s_z + hdiv6 * (m1 + 2.0 * m2 + 2.0 * m3 + m4);
+ s_t = t_arg;
+ }
+
+ return true;
+ }
+
+ private static double F(double t, double x, double y, double z)
+ {
+ return (10.0 * (y - x));
+ }
+
+ private static double G(double t, double x, double y, double z)
+ {
+ return (x * (28.0 - z) - y);
+ }
+
+ private static double H(double t, double x, double y, double z)
+ {
+ return (x * y - (8.0 * z) / 3.0);
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Lorenz.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class MatInv4
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 60;
+#endif
+
+ private static float s_det;
+
+ private struct X
+ {
+ public float[] A;
+ public X(int size)
+ {
+ A = new float[size];
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ X a = new X(Iterations * Iterations);
+ float[] b = new float[Iterations * Iterations];
+ float[] c = new float[Iterations * Iterations];
+ float[] d = new float[Iterations * Iterations];
+ float[] l1 = new float[Iterations];
+ float[] l2 = new float[Iterations];
+
+ int i, k, n, nsq;
+
+ n = Iterations;
+ nsq = n * n;
+ for (i = 0; i < n; ++i)
+ {
+ for (k = 0; k < n; ++k)
+ {
+ if (i == k)
+ {
+ a.A[i * n + k] = 40.0F;
+ }
+ else
+ {
+ a.A[i * n + k] = 0.0F;
+ }
+ }
+ }
+
+ for (i = 0; i < n; ++i)
+ {
+ for (k = i; k < nsq; k += n)
+ {
+ b[k] = a.A[k];
+ }
+ }
+
+ /*** second(&t1); ***/
+
+ MinV1(b, ref n, out s_det, l1, l2);
+
+ if (s_det == 0.0F)
+ {
+ goto L990;
+ }
+
+ /*** second(&tx); ***/
+
+ MProd(b, a.A, c, ref n);
+ for (k = 1; k <= nsq; ++k)
+ {
+ b[k - 1] = a.A[k - 1];
+ }
+
+ /*** second(&tx); ***/
+
+ MinV2(b, ref n, out s_det, l1, l2);
+
+ if (s_det == 0.0F)
+ {
+ goto L990;
+ }
+
+ /*** second(&ty); ***/
+
+ MProd(b, a.A, d, ref n);
+ CompM(c, d, ref n);
+
+ /*** second(&t2); ***/
+
+ return true;
+
+ L990:
+ {
+ }
+
+ return true;
+ }
+
+ private static void MinV1(float[] a, ref int n, out float d, float[] l, float[] m)
+ {
+ float biga, hold;
+ int i, j, k, ij, ik, ji, jk, nk, ki, kj, kk, iz, jp, jq, jr;
+
+ d = 1.0F;
+ ji = 0;
+ hold = 0.0F;
+ nk = -n;
+ for (k = 1; k <= n; ++k)
+ {
+ nk = nk + n;
+ l[k - 1] = k;
+ m[k - 1] = k;
+ kk = nk + k;
+ biga = a[kk - 1];
+ for (j = k; j <= n; ++j)
+ {
+ // j <= n, so iz <= n^2 - n
+ iz = n * (j - 1);
+ for (i = k; i <= n; ++i)
+ {
+ // iz <= n^2 - n and i <= n, so ij <= n^2
+ ij = iz + i;
+ if (System.Math.Abs(biga) >= System.Math.Abs(a[ij - 1]))
+ {
+ continue;
+ }
+ // accessing up to n^2 - 1
+ biga = a[ij - 1];
+ l[k - 1] = i;
+ m[k - 1] = j;
+ }
+ }
+
+ j = (int)l[k - 1];
+
+ if (j <= k)
+ {
+ goto L35;
+ }
+
+ // -n < ki <= 0
+ ki = k - n;
+ for (i = 1; i <= n; ++i)
+ {
+ // i <= n, ki <= n + n + ... + n (n times) i.e. k <= n * n (when ki = 0 initially)
+ ki = ki + n;
+ // Accessing upto n^2 -1
+ hold = -a[ki - 1];
+ // ji <= n^2 - n + n (for ki = 0 initially when k = n and 0 < j <= n)
+ // Therefore ji <= n^2
+ ji = ki - k + j;
+ a[ki - 1] = a[ji - 1];
+ a[ji - 1] = hold;
+ }
+ L35:
+ i = (int)m[k - 1];
+ if (i <= k)
+ {
+ goto L45;
+ }
+
+ // 0 <= jp <= n^2 - n
+ jp = n * (i - 1);
+ for (j = 1; j <= n; ++j)
+ {
+ // 0 < nk <= n * (n-1)
+ // jk <= n^2 - n + n
+ // jk <= n^2
+ jk = nk + j;
+ // jp <= n^2 - n
+ // ji <= n^2 - n + n or ji <= n^2 (since 0 < j <= n)
+ ji = jp + j;
+ hold = -a[jk - 1];
+ a[jk - 1] = a[ji - 1];
+ a[ji - 1] = hold;
+ }
+ L45:
+ if (biga != 0.0F)
+ {
+ goto L48;
+ }
+ d = 0.0F;
+ return;
+
+ L48:
+ for (i = 1; i <= n; ++i)
+ {
+ if (i == k)
+ {
+ break;
+ }
+ // 0 < nk <= n * (n-1)
+ // 0 < ik <= n^2
+ ik = nk + i;
+ a[ik - 1] = a[ik - 1] / (-biga);
+ }
+
+ for (i = 1; i <= n; ++i)
+ {
+ if (i == k)
+ {
+ continue;
+ }
+ // 0 < nk <= n * (n-1)
+ // 0 < ik <= n^2
+ ik = nk + i;
+ hold = a[ik - 1];
+ // -n < ij <= 0
+ ij = i - n;
+ for (j = 1; j <= n; ++j)
+ {
+ // i <= n, ij <= n + n + ... + n (n times) or ij <= n * n
+ ij = ij + n;
+ if (j == k)
+ {
+ continue;
+ }
+ // if i=1, kj = (1 + (n-1) * n) - 1 + n ==> ij = n^2
+ // if i=n, kj = (n * n) - n + n ==> ij = n ^2
+ // So j <= n^2
+ kj = ij - i + k;
+ a[ij - 1] = hold * a[kj - 1] + a[ij - 1];
+ }
+ }
+ kj = k - n;
+ for (j = 1; j <= n; ++j)
+ {
+ // k <= n, kj <= n + n + ... + n (n times) or kj <= n * n
+ kj = kj + n;
+ if (j == k)
+ {
+ continue;
+ }
+ // Accessing upto n^2 - 1
+ a[kj - 1] = a[kj - 1] / biga;
+ }
+ d = d * biga;
+ a[kk - 1] = 1.0F / biga;
+ }
+ k = n;
+ L100:
+ k = k - 1;
+ if (k < 1)
+ {
+ return;
+ }
+ i = (int)l[k - 1];
+ if (i <= k)
+ {
+ goto L120;
+ }
+
+ // 0 <= jq <= n^2 - n
+ // 0 <= jr <= n^2 - n
+ jq = n * (k - 1);
+ jr = n * (i - 1);
+ for (j = 1; j <= n; ++j)
+ {
+ // jk <= n^2 - n + n
+ // jk <= n^2
+ jk = jq + j;
+ hold = a[jk - 1];
+ // ji <= n^2 - n + n
+ // ji <= n^2
+ ji = jr + j;
+ a[jk - 1] = -a[ji - 1];
+ a[ji - 1] = hold;
+ }
+ L120:
+ j = (int)m[k - 1];
+ if (j <= k)
+ {
+ goto L100;
+ }
+ // 0 <= jr <= n^2 - n
+ ki = k - n;
+ for (i = 1; i <= n; ++i)
+ {
+ // ki <= n + n + ... + n (n times) or ki <= n * n
+ ki = ki + n;
+ hold = a[ki - 1];
+ // if i=1, ji = (1 + (n-1) * n) - 1 + n ==> ij = n^2
+ // if i=n, ji = (n * n) - n + n ==> ij = n ^2
+ // Therefore ji <= n^2
+ ji = ki - k + j;
+ a[ki - 1] = -a[ji - 1];
+ }
+ a[ji - 1] = hold;
+ goto L100;
+ }
+
+ private static void MinV2(float[] a, ref int n, out float d, float[] l, float[] m)
+ {
+ float biga, hold;
+ int i, j, k;
+
+ d = 1.0F;
+ for (k = 1; k <= n; ++k)
+ {
+ l[k - 1] = k;
+ m[k - 1] = k;
+ biga = a[(k - 1) * n + (k - 1)];
+ for (j = k; j <= n; ++j)
+ {
+ for (i = k; i <= n; ++i)
+ {
+ // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
+ if (System.Math.Abs(biga) >= System.Math.Abs(a[(i - 1) * n + (j - 1)]))
+ {
+ continue;
+ }
+ biga = a[(i - 1) * n + (j - 1)];
+ l[k - 1] = i;
+ m[k - 1] = j;
+ }
+ }
+ j = (int)l[k - 1];
+ if (l[k - 1] <= k)
+ {
+ goto L200;
+ }
+ for (i = 1; i <= n; ++i)
+ {
+ // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
+ hold = -a[(k - 1) * n + (i - 1)];
+ a[(k - 1) * n + (i - 1)] = a[(j - 1) * n + (i - 1)];
+ a[(j - 1) * n + (i - 1)] = hold;
+ }
+ L200:
+ i = (int)m[k - 1];
+ if (m[k - 1] <= k)
+ {
+ goto L250;
+ }
+ for (j = 1; j <= n; ++j)
+ {
+ // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
+ hold = -a[(j - 1) * n + (k - 1)];
+ a[(j - 1) * n + (k - 1)] = a[(j - 1) * n + (i - 1)];
+ a[(j - 1) * n + (i - 1)] = hold;
+ }
+ L250:
+ if (biga != 0.0F)
+ {
+ goto L300;
+ }
+ d = 0.0F;
+ return;
+
+ L300:
+ for (i = 1; i <= n; ++i)
+ {
+ if (i != k)
+ {
+ // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
+ a[(i - 1) * n + (k - 1)] = a[(i - 1) * n + (k - 1)] / (-biga);
+ }
+ }
+ for (i = 1; i <= n; ++i)
+ {
+ if (i == k)
+ {
+ continue;
+ }
+ for (j = 1; j <= n; ++j)
+ {
+ if (j != k)
+ {
+ // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
+ a[(i - 1) * n + (j - 1)] = a[(i - 1) * n + (k - 1)] * a[(k - 1) * n + (j - 1)] + a[(i - 1) * n + (j - 1)];
+ }
+ }
+ }
+ for (j = 1; j < n; ++j)
+ {
+ if (j != k)
+ {
+ // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
+ a[(k - 1) * n + (j - 1)] = a[(k - 1) * n + (j - 1)] / biga;
+ }
+ }
+ d = d * biga;
+ a[(k - 1) * n + (k - 1)] = 1.0F / biga;
+ }
+ k = n;
+ L400:
+ k = k - 1;
+ if (k < 1)
+ {
+ return;
+ }
+ i = (int)l[k - 1];
+ if (i <= k)
+ {
+ goto L450;
+ }
+ for (j = 1; j <= n; ++j)
+ {
+ // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
+ hold = a[(j - 1) * n + (k - 1)];
+ a[(j - 1) * n + (k - 1)] = -a[(j - 1) * n + (i - 1)];
+ a[(j - 1) * n + (i - 1)] = hold;
+ }
+ L450:
+ j = (int)m[k - 1];
+ if (j <= k)
+ {
+ goto L400;
+ }
+ for (i = 1; i <= n; ++i)
+ {
+ // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
+ hold = a[(k - 1) * n + (i - 1)];
+ a[(k - 1) * n + (i - 1)] = -a[(j - 1) * n + (i - 1)];
+ a[(j - 1) * n + (i - 1)] = hold;
+ }
+ goto L400;
+ }
+
+ private static void MProd(float[] a, float[] b, float[] c, ref int n)
+ {
+ int i, j, k;
+
+ for (i = 1; i <= n; ++i)
+ {
+ for (j = 1; j <= n; ++j)
+ {
+ // Accessing upto n^2 - n + n - 1 ==> n^2 - 1
+ c[(i - 1) * n + (j - 1)] = 0.0F;
+ for (k = 1; k <= n; ++k)
+ {
+ c[(i - 1) * n + (j - 1)] = c[(i - 1) * n + (j - 1)] + a[(i - 1) * n + (k - 1)] * b[(k - 1) * n + (j - 1)];
+ }
+ }
+ }
+ return;
+ }
+
+ private static void CompM(float[] a, float[] b, ref int n)
+ {
+ int i, j;
+ float x, sum = 0.0F;
+
+ //(starting compare.)
+ for (i = 1; i <= n; ++i)
+ {
+ for (j = 1; j <= n; ++j)
+ {
+ x = 0.0F;
+ if (i == j)
+ {
+ x = 1.0F;
+ }
+ sum = sum + System.Math.Abs(System.Math.Abs(a[(i - 1) * n + (j - 1)]) - x);
+ }
+ }
+ return;
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="MatInv4.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// Simultaneous equations by Newton's method adapted from Conte and De Boor
+// to solve F(X,Y)=0 and G(X,Y)=0
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class NewtE
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 1000000;
+#endif
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ double idgb, a, b, x, y, deltaX, deltaY;
+ a = 0;
+ b = 0;
+ x = 0;
+ y = 0;
+ idgb = 0;
+
+ if (idgb != 0)
+ {
+ System.Console.WriteLine("{0}, {1}, F(x,y) , G(x,y) \n", x, y);
+ }
+
+ for (int j = 1; j <= Iterations; j++)
+ {
+ x = 1.0;
+ y = (-2.0);
+ a = F(x, y);
+ b = G(x, y);
+ if (idgb != 0)
+ {
+ System.Console.WriteLine(" {0}, {1}, {2}, {3}\n", x, y, a, b);
+ }
+
+ for (int i = 1; i <= 20; i++)
+ {
+ deltaX = (-F(x, y) * GY(x, y) + G(x, y) * FY(x, y)) / (FX(x, y) * GY(x, y) - FY(x, y) * GX(x, y));
+ deltaY = (-G(x, y) * FX(x, y) + F(x, y) * GX(x, y)) / (FX(x, y) * GY(x, y) - FY(x, y) * GX(x, y));
+ x = x + deltaX;
+ y = y + deltaY;
+ a = F(x, y);
+ b = G(x, y);
+ if (idgb != 0)
+ {
+ System.Console.WriteLine("{0}, {1}, {2}, {3}, {4}\n", i, x, y, a, b);
+ }
+
+ if ((System.Math.Abs(deltaX) < 0.000001) && (System.Math.Abs(deltaY) < 0.000001) &&
+ (System.Math.Abs(a) < 0.000001) && (System.Math.Abs(b) < 0.000001))
+ {
+ goto L11;
+ }
+ }
+ if (idgb != 0)
+ {
+ System.Console.WriteLine("FAILED TO CONVERGE IN 20 ITERATIONS\n");
+ }
+
+ L11:
+ {
+ }
+ }
+
+ return true;
+ }
+
+ private static double F(double x, double y)
+ {
+ return ((x) + 3 * System.Math.Log(x) / System.Math.Log(10.0) - (y) * (y));
+ }
+
+ private static double G(double x, double y)
+ {
+ return (2 * (x) * (x) - (x) * (y) - 5 * (x) + 1);
+ }
+
+ private static double FX(double x, double y)
+ {
+ return (1 + 3 / (System.Math.Log(10.0) * (x)));
+ }
+
+ private static double FY(double x, double y)
+ {
+ return ((-2) * (y));
+ }
+
+ private static double GX(double x, double y)
+ {
+ return (4 * (x) - (y) - 5);
+ }
+
+ private static double GY(double x, double y)
+ {
+ return (-(x));
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="NewtE.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// Newton's method adapted from Conte and De Boor
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class NewtR
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 80000000;
+#endif
+
+ public static volatile object VolatileObject;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static void Escape(object obj)
+ {
+ VolatileObject = obj;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ int idbg, iflag;
+ double x0, fx0;
+
+ iflag = 0;
+ idbg = 0;
+ fx0 = 0.0;
+ x0 = 1.0;
+
+ for (int i = 1; i <= Iterations; i++)
+ {
+ Inner(ref x0, 0.0000001, 0.0000001, 10, out iflag);
+ if (iflag > 1)
+ {
+ goto L888;
+ }
+
+ fx0 = FF(x0);
+ if (idbg != 0)
+ {
+ System.Console.WriteLine(" THE ROOT IS {0:e} F(ROOT) := {1:E}\n", x0, fx0);
+ }
+
+ L888:
+ {
+ }
+ }
+
+ // Escape iflag, x0, and fx0 so that they appear live
+ Escape(iflag);
+ Escape(x0);
+ Escape(fx0);
+
+ return true;
+ }
+
+ private static double FF(double x)
+ {
+ return (-1.0 - ((x) * (1.0 - ((x) * (x)))));
+ }
+
+ private static double FFDer(double x)
+ {
+ return (3.0 * (x) * (x) - 1.0);
+ }
+
+ private static void Inner(ref double x0, double xtol, double ftol, int ntol, out int iflag)
+ {
+ double fx0, deriv, deltax;
+
+ iflag = 0;
+ for (int n = 1; n <= ntol; n++)
+ {
+ fx0 = FF(x0);
+ if (System.Math.Abs(fx0) < ftol)
+ {
+ goto L999;
+ }
+ deriv = FFDer(x0);
+
+ if (deriv == 0.0)
+ {
+ goto L999;
+ }
+ deltax = fx0 / deriv;
+ x0 = x0 - deltax;
+ if (System.Math.Abs(deltax) < xtol)
+ {
+ goto L999;
+ }
+ }
+ L999:
+ iflag = 2;
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="NewtR.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// The modified regula-falsi routine adapted from Conte and De Boor
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class Regula
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 4000000;
+#endif
+
+ public static volatile object VolatileObject;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static void Escape(object obj)
+ {
+ VolatileObject = obj;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ double error, fxi;
+ double a, b, xi;
+ int idbg, iflag;
+
+ iflag = 0;
+ idbg = 0;
+ xi = 0;
+ error = 0.0;
+ fxi = 0.0;
+
+ for (int i = 1; i <= Iterations; i++)
+ {
+ a = 1.0;
+ b = 2.0;
+ Inner(ref a, ref b, 0.0000001, 0.0000000001, 30, out iflag);
+ if (iflag > 2)
+ {
+ goto L999;
+ }
+
+ xi = (a + b) / 2.0;
+ error = System.Math.Abs(b - a) / 2.0;
+ fxi = FG(xi);
+
+ if (idbg != 0)
+ {
+ System.Console.WriteLine(" the root is {0:E}", xi);
+ System.Console.WriteLine(" plus/minus {0}\n", error);
+ System.Console.WriteLine(" fg(root):= {0:E}\n", fxi);
+ }
+
+ L999:
+ {
+ }
+ }
+
+ // Escape iflag, xi, error, and fxi so that they appear live
+ Escape(iflag);
+ Escape(xi);
+ Escape(error);
+ Escape(fxi);
+
+ return true;
+ }
+
+ private static double FG(double x)
+ {
+ return (-1.0 - (x * (1.0 - (x * x))));
+ }
+
+ private static void Inner(ref double a, ref double b, double xtol, double ftol, int ntol, out int iflag)
+ {
+ double signfa, prevfw, fa, fb, fw, w;
+
+ iflag = 0;
+ fa = FG(a);
+ if (fa < 0.0)
+ {
+ signfa = -1.0;
+ }
+ else
+ {
+ signfa = 1.0;
+ }
+
+ fb = FG(b);
+ if (signfa * fb <= 0.0)
+ {
+ goto L5;
+ }
+
+ iflag = 3;
+ goto L99;
+
+ L5:
+ w = a;
+ fw = fa;
+ for (int i = 1; i <= ntol; i++)
+ {
+ if (System.Math.Abs(b - a) / 2.0 <= xtol)
+ {
+ goto L99;
+ }
+ if (System.Math.Abs(fw) > ftol)
+ {
+ goto L9;
+ }
+
+ a = w;
+ b = w;
+ iflag = 1;
+ goto L99;
+
+ L9:
+ w = (fa * b - fb * a) / (fa - fb);
+ if (fw < 0.0)
+ {
+ prevfw = -1.0;
+ }
+ else
+ {
+ prevfw = 1.0;
+ }
+ fw = FG(w);
+
+ if (signfa * fw < 0.0)
+ {
+ goto L10;
+ }
+ a = w;
+ fa = fw;
+ if (fw * prevfw > 0.0)
+ {
+ fb = fb / 2.0;
+ }
+ goto L20;
+
+ L10:
+ b = w;
+ fb = fw;
+ if (fw * prevfw > 0.0)
+ {
+ fa = fa / 2.0;
+ }
+
+ L20:
+ {
+ }
+ }
+
+ iflag = 2;
+ L99:
+ {
+ }
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Regula.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// Integration by romberg method adapted from Conte and de Boor
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class Romber
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 640000;
+#endif
+
+ private static T[][] AllocArray<T>(int n1, int n2)
+ {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i)
+ {
+ a[i] = new T[n2];
+ }
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ double[][] r = AllocArray<double>(11, 11);
+ double[][] t = AllocArray<double>(11, 11);
+
+ int idbg, m, n, i, kmax, fourj, j, kmaxm2, l, k, mm1;
+ double sum, ratio, t1, h, a, b;
+
+ for (l = 1; l <= Iterations; l++)
+ {
+ idbg = 0;
+ m = 2;
+ kmax = 6;
+ a = 0;
+ b = 1;
+ h = (b - a) / (m);
+ sum = (F(a) + F(b)) / 2;
+
+ mm1 = m - 1;
+ if (mm1 < 0)
+ {
+ goto L40;
+ }
+ if (mm1 == 0)
+ {
+ goto L10;
+ }
+ for (i = 1; i <= mm1; i++)
+ {
+ t1 = a + i * h;
+ sum = sum + F(t1);
+ }
+
+ L10:
+ t[1][1] = sum * h;
+ if (idbg != 0)
+ {
+ System.Console.WriteLine(" romberg t-table \n");
+ System.Console.WriteLine("{0}\n", t[1][1]);
+ }
+
+ for (k = 2; k <= kmax; k++)
+ {
+ h = h / 2;
+ n = m * 2;
+ sum = 0;
+ for (i = 1; i <= n / 2; i++)
+ {
+ r[k][1] = r[k - 1][1] * System.Math.Sqrt(b * mm1);
+ t1 = a + i * h;
+ sum = sum + F(t1);
+ }
+
+ t[k][1] = t[k - 1][1] / 2 + sum * h;
+ fourj = 1;
+ for (j = 2; j <= k; j++)
+ {
+ fourj = fourj * 4;
+ t[k - 1][j - 1] = t[k][j - 1] - t[k - 1][j - 1];
+ t[k][j] = t[k][j - 1] + t[k - 1][j - 1] / (fourj - 1);
+ }
+
+ if (idbg != 0)
+ {
+ j = 1;
+ System.Console.WriteLine("{0} {1} {2}d\n", t[k][j], j, k);
+ }
+ }
+
+ kmaxm2 = kmax - 2;
+ if (kmaxm2 <= 0)
+ {
+ goto L40;
+ }
+
+ if (idbg != 0)
+ {
+ System.Console.WriteLine(" table of ratios \n");
+ }
+
+ for (k = 1; k <= kmaxm2; k++)
+ {
+ for (j = 1; j <= k; j++)
+ {
+ ratio = 0;
+ if (System.Math.Abs(t[k + 1][j]) > 0)
+ {
+ ratio = t[k][j] / t[k + 1][j];
+ }
+ t[k][j] = ratio;
+ }
+ }
+
+ if (idbg != 0)
+ {
+ j = 1;
+ System.Console.WriteLine("{0} {1} {2}\n", t[k][j], j, k);
+ }
+
+ L40:
+ {
+ }
+ }
+
+ return true;
+ }
+
+ private static double F(double x)
+ {
+ return (System.Math.Exp((-(x)) * (x)));
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Romber.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// The secant algorithm adapted from Conte and DeBoor
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class Secant
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 3000000;
+#endif
+
+ public static volatile object VolatileObject;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static void Escape(object obj)
+ {
+ VolatileObject = obj;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ int idbg, iflag;
+ double x0, x1, fx1;
+
+ iflag = 0;
+ idbg = 0;
+ x1 = 0;
+ fx1 = 0.0;
+
+ for (int i = 1; i <= Iterations; i++)
+ {
+ x0 = 1.0;
+ x1 = 2.0;
+ Inner(ref x0, ref x1, 0.0000001, 0.0000001, 30, out iflag);
+ if (iflag > 1)
+ {
+ goto L888;
+ }
+
+ fx1 = FF(x1);
+ if (idbg != 0)
+ {
+ System.Console.WriteLine(" the root is {0:E}, F(ROOT):= {1:E}\n", x1, fx1);
+ }
+ L888:
+ {
+ }
+ }
+
+ // Escape iflag, x1, and fx1 so that they appear live
+ Escape(iflag);
+ Escape(x1);
+ Escape(fx1);
+
+ return true;
+ }
+
+ private static double FF(double x)
+ {
+ return (-1.0 - (x * (1.0 - (x * x))));
+ }
+
+ private static void Inner(ref double x0, ref double x1, double xtol, double ftol, int ntol, out int iflag)
+ {
+ double deltax, deltaf, f0, f1;
+
+ iflag = 0;
+ f0 = FF(x0);
+ deltax = x1 - x0;
+
+ for (int n = 1; n <= ntol; n++)
+ {
+ f1 = FF(x1);
+
+ if (System.Math.Abs(f1) <= ftol)
+ {
+ goto L30;
+ }
+
+ deltaf = f0 - f1;
+ if (deltaf == 0.0)
+ {
+ goto L999;
+ }
+
+ deltax = f1 / deltaf * deltax;
+ x0 = x1;
+ x1 = x1 + deltax;
+ if (System.Math.Abs(deltax) <= xtol)
+ {
+ goto L88;
+ }
+
+ f0 = f1;
+ }
+
+ L999:
+ iflag = 2;
+ goto L88;
+ L30:
+ iflag = 1;
+ L88:
+ {
+ }
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Secant.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// Integration by Simpson's rule adapted from Conte and de Boor
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class Simpsn
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 90000;
+#endif
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ double a, b, x, s, c, h, hov2, half, t1;
+ int idbg, n, nm1;
+
+ s = 0;
+ idbg = 0;
+ if (idbg != 0)
+ {
+ System.Console.WriteLine("simpsons rule\n");
+ }
+
+ for (int j = 1; j <= Iterations; j++)
+ {
+ a = 0;
+ b = 1;
+ c = 4;
+ n = 100;
+ h = (b - a) / n;
+ hov2 = h / System.Math.Sqrt(c);
+ s = 0;
+ t1 = a + hov2;
+ half = F(t1);
+ nm1 = n - 1;
+ for (int i = 1; i <= nm1; i++)
+ {
+ x = a + i * h;
+ s = s + F(x);
+ t1 = x + hov2;
+ half = half + F(t1);
+ s = (h / 6) * (F(a) + 4 * half + 2 * s + F(b));
+ if (idbg != 0)
+ {
+ System.Console.WriteLine(" integral from a = {0} to b = {1} for n = {2} is {3}\n", a, b, n, s);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private static double F(double x)
+ {
+ return (System.Math.Exp((-(x)) * 2));
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Simpsn.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class SqMtx
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 4000;
+#endif
+
+ private const int MatrixSize = 40;
+
+ private static T[][] AllocArray<T>(int n1, int n2)
+ {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i)
+ {
+ a[i] = new T[n2];
+ }
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ double[][] a = AllocArray<double>(41, 41);
+ double[][] c = AllocArray<double>(41, 41);
+
+ int i, j;
+
+ for (i = 1; i <= MatrixSize; i++)
+ {
+ for (j = 1; j <= MatrixSize; j++)
+ {
+ a[i][j] = i + j;
+ }
+ }
+
+ for (i = 1; i <= Iterations; i++)
+ {
+ Inner(a, c, MatrixSize);
+ }
+
+ if (c[1][1] == 23820.0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ private static void Inner(double[][] a, double[][] c, int n)
+ {
+ for (int i = 1; i <= n; i++)
+ {
+ for (int j = 1; j <= n; j++)
+ {
+ c[i][j] = 0.0;
+ for (int k = 1; k <= n; k++)
+ {
+ c[i][j] = c[i][j] + a[i][k] * a[k][j];
+ }
+ }
+ }
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="SqMtx.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// Integration by corrected trapezoid rule adapted from Conte and de Boor
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class Trap
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 240000;
+#endif
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ int nm1, idbg;
+ double t2, cortrp, trap, a, b, h;
+ trap = 0.0;
+ cortrp = 0.0;
+
+ idbg = 0;
+ for (int j = 1; j <= Iterations; j++)
+ {
+ a = 0;
+ b = 1;
+ if (idbg != 0)
+ {
+ System.Console.WriteLine("trapazoid sum corr.trap sum \n");
+ }
+
+ for (int n = 10; n <= 15; n++)
+ {
+ h = (b - a) / n;
+ nm1 = n - 1;
+ trap = (F(a) + F(b)) / 2;
+ for (int i = 1; i <= nm1; i++)
+ {
+ t2 = a + i * h;
+ trap = trap + F(t2);
+ }
+ trap = trap * h;
+ cortrp = trap + h * h * (FPrime(a) - FPrime(b)) / 12;
+ if (idbg != 0)
+ {
+ System.Console.WriteLine("{0}, {1}, {2}\n", n, trap, cortrp);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private static double F(double x)
+ {
+ return (System.Math.Exp(-(x) * (x)));
+ }
+
+ private static double FPrime(double x)
+ {
+ return ((-2) * (x) * (F(x)));
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Trap.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// C# translation of Whetstone Double Precision Benchmark
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchF
+{
+public static class Whetsto
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 50000;
+#endif
+
+ private static int s_j, s_k, s_l;
+ private static double s_t, s_t2;
+
+ public static volatile int Volatile_out;
+
+ private static void Escape(int n, int j, int k, double x1, double x2, double x3, double x4)
+ {
+ Volatile_out = n;
+ Volatile_out = j;
+ Volatile_out = k;
+ Volatile_out = (int)x1;
+ Volatile_out = (int)x2;
+ Volatile_out = (int)x3;
+ Volatile_out = (int)x4;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ double[] e1 = new double[4];
+ double x1, x2, x3, x4, x, y, z, t1;
+ int i, n1, n2, n3, n4, n6, n7, n8, n9, n10, n11;
+
+ s_t = 0.499975;
+ t1 = 0.50025;
+ s_t2 = 2.0;
+ n1 = 0 * Iterations;
+ n2 = 12 * Iterations;
+ n3 = 14 * Iterations;
+ n4 = 345 * Iterations;
+ n6 = 210 * Iterations;
+ n7 = 32 * Iterations;
+ n8 = 899 * Iterations;
+ n9 = 616 * Iterations;
+ n10 = 0 * Iterations;
+ n11 = 93 * Iterations;
+ x1 = 1.0;
+ x2 = x3 = x4 = -1.0;
+
+ for (i = 1; i <= n1; i += 1)
+ {
+ x1 = (x1 + x2 + x3 - x4) * s_t;
+ x2 = (x1 + x2 - x3 - x4) * s_t;
+ x3 = (x1 - x2 + x3 + x4) * s_t;
+ x4 = (-x1 + x2 + x3 + x4) * s_t;
+ }
+ Escape(n1, n1, n1, x1, x2, x3, x4);
+
+ /* MODULE 2: array elements */
+ e1[0] = 1.0;
+ e1[1] = e1[2] = e1[3] = -1.0;
+ for (i = 1; i <= n2; i += 1)
+ {
+ e1[0] = (e1[0] + e1[1] + e1[2] - e1[3]) * s_t;
+ e1[1] = (e1[0] + e1[1] - e1[2] + e1[3]) * s_t;
+ e1[2] = (e1[0] - e1[1] + e1[2] + e1[3]) * s_t;
+ e1[3] = (-e1[0] + e1[1] + e1[2] + e1[3]) * s_t;
+ }
+ Escape(n2, n3, n2, e1[0], e1[1], e1[2], e1[3]);
+
+ /* MODULE 3: array as parameter */
+ for (i = 1; i <= n3; i += 1)
+ {
+ PA(e1);
+ }
+ Escape(n3, n2, n2, e1[0], e1[1], e1[2], e1[3]);
+
+ /* MODULE 4: conditional jumps */
+ s_j = 1;
+ for (i = 1; i <= n4; i += 1)
+ {
+ if (s_j == 1)
+ {
+ s_j = 2;
+ }
+ else
+ {
+ s_j = 3;
+ }
+ if (s_j > 2)
+ {
+ s_j = 0;
+ }
+ else
+ {
+ s_j = 1;
+ }
+ if (s_j < 1)
+ {
+ s_j = 1;
+ }
+ else
+ {
+ s_j = 0;
+ }
+ }
+ Escape(n4, s_j, s_j, x1, x2, x3, x4);
+
+ /* MODULE 5: omitted */
+ /* MODULE 6: integer Math */
+ s_j = 1;
+ s_k = 2;
+ s_l = 3;
+ for (i = 1; i <= n6; i += 1)
+ {
+ s_j = s_j * (s_k - s_j) * (s_l - s_k);
+ s_k = s_l * s_k - (s_l - s_j) * s_k;
+ s_l = (s_l - s_k) * (s_k + s_j);
+ e1[s_l - 2] = s_j + s_k + s_l;
+ e1[s_k - 2] = s_j * s_k * s_l;
+ }
+ Escape(n6, s_j, s_k, e1[0], e1[1], e1[2], e1[3]);
+
+ /* MODULE 7: trig. functions */
+ x = y = 0.5;
+ for (i = 1; i <= n7; i += 1)
+ {
+ x = s_t * System.Math.Atan(s_t2 * System.Math.Sin(x) * System.Math.Cos(x) / (System.Math.Cos(x + y) + System.Math.Cos(x - y) - 1.0));
+ y = s_t * System.Math.Atan(s_t2 * System.Math.Sin(y) * System.Math.Cos(y) / (System.Math.Cos(x + y) + System.Math.Cos(x - y) - 1.0));
+ }
+ Escape(n7, s_j, s_k, x, x, y, y);
+
+ /* MODULE 8: procedure calls */
+ x = y = z = 1.0;
+ for (i = 1; i <= n8; i += 1)
+ {
+ P3(x, y, out z);
+ }
+ Escape(n8, s_j, s_k, x, y, z, z);
+
+ /* MODULE9: array references */
+ s_j = 1;
+ s_k = 2;
+ s_l = 3;
+ e1[0] = 1.0;
+ e1[1] = 2.0;
+ e1[2] = 3.0;
+ for (i = 1; i <= n9; i += 1)
+ {
+ P0(e1);
+ }
+ Escape(n9, s_j, s_k, e1[0], e1[1], e1[2], e1[3]);
+
+ /* MODULE10: integer System.Math */
+ s_j = 2;
+ s_k = 3;
+ for (i = 1; i <= n10; i += 1)
+ {
+ s_j = s_j + s_k;
+ s_k = s_j + s_k;
+ s_j = s_k - s_j;
+ s_k = s_k - s_j - s_j;
+ }
+ Escape(n10, s_j, s_k, x1, x2, x3, x4);
+
+ /* MODULE11: standard functions */
+ x = 0.75;
+ for (i = 1; i <= n11; i += 1)
+ {
+ x = System.Math.Sqrt(System.Math.Exp(System.Math.Log(x) / t1));
+ }
+ Escape(n11, s_j, s_k, x, x, x, x);
+
+ return true;
+ }
+
+ private static void PA(double[] e)
+ {
+ int j;
+ j = 0;
+ lab:
+ e[0] = (e[0] + e[1] + e[2] - e[3]) * s_t;
+ e[1] = (e[0] + e[1] - e[2] + e[3]) * s_t;
+ e[2] = (e[0] - e[1] + e[2] + e[3]) * s_t;
+ e[3] = (-e[0] + e[1] + e[2] + e[3]) / s_t2;
+ j += 1;
+ if (j < 6)
+ {
+ goto lab;
+ }
+ }
+
+ private static void P3(double x, double y, out double z)
+ {
+ x = s_t * (x + y);
+ y = s_t * (x + y);
+ z = (x + y) / s_t2;
+ }
+
+ private static void P0(double[] e1)
+ {
+ e1[s_j] = e1[s_k];
+ e1[s_k] = e1[s_l];
+ e1[s_l] = e1[s_j];
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Whetsto.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class EightQueens
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 100000;
+#endif
+
+ static int[] m_c = new int[15];
+ static int[] m_x = new int[9];
+
+ static void TryMe(int i, ref int q, int[] a, int[] b)
+ {
+ int j = 0;
+ q = 0;
+ while ((q == 0) && (j != 8)) {
+ j = j + 1;
+ q = 0;
+ if ((b[j] == 1) && (a[i + j] == 1) && (m_c[i - j + 7] == 1)) {
+ m_x[i] = j;
+ b[j] = 0;
+ a[i + j] = 0;
+ m_c[i - j + 7] = 0;
+ if (i < 8) {
+ TryMe(i + 1, ref q, a, b);
+ if (q == 0) {
+ b[j] = 1;
+ a[i + j] = 1;
+ m_c[i - j + 7] = 1;
+ }
+ }
+ else {
+ q = 1;
+ }
+ }
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ int[] a = new int[9];
+ int[] b = new int[17];
+ int q = 0;
+ int i = 0;
+ while (i <= 16) {
+ if ((i >= 1) && (i <= 8)) {
+ a[i] = 1;
+ }
+ if (i >= 2) {
+ b[i] = 1;
+ }
+ if (i <= 14) {
+ m_c[i] = 1;
+ }
+ i = i + 1;
+ }
+
+ TryMe(1, ref q, b, a);
+
+ return (q == 1);
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench();
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = true;
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench();
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="8Queens.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class Ackermann
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 100000;
+#endif
+
+ static int Acker(int m, int n) {
+ if (m == 0) {
+ return n + 1;
+ }
+ else if (n == 0) {
+ return Acker(m - 1, 1);
+ }
+ else {
+ return Acker(m - 1, Acker(m, n - 1));
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ int a00 = Acker(0, 0);
+ int a11 = Acker(1, 1);
+ int a22 = Acker(2, 2);
+ int a33 = Acker(3, 3);
+ return (a00 == 1) && (a11 == 3) && (a22 == 7) & (a33 == 61);
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench();
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = true;
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench();
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Ackermann.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class AddArray
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 15000;
+#endif
+
+ const int Size = 6000;
+
+ public static volatile object VolatileObject;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static void Escape(object obj) {
+ VolatileObject = obj;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+
+ int[] flags1 = new int[Size + 1];
+ int[] flags2 = new int[Size + 1];
+ int[] flags3 = new int[Size + 1];
+ int[] flags4 = new int[Size + 1];
+
+ int j, k, l, m;
+
+ for (j = 0; j <= Size; j++) {
+ flags1[j] = 70000 + j;
+ k = j;
+ flags2[k] = flags1[j] + k + k;
+ l = j;
+ flags3[l] = flags2[k] + l + l + l;
+ m = j;
+ flags4[m] = flags3[l] + m + m + m + m;
+ }
+
+ for (j = 0; j <= Size; j++) {
+ k = j;
+ l = j;
+ m = j;
+ flags1[j] = flags1[j] + flags2[k] + flags3[l] + flags4[m] - flags2[k - j + l];
+ }
+
+ // Escape each flags array so that their elements will appear live-out
+ Escape(flags1);
+ Escape(flags2);
+ Escape(flags3);
+ Escape(flags4);
+
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench();
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = true;
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench();
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AddArray.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class AddArray2
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 50;
+#endif
+
+ private const int Dim = 200;
+
+ private static T[][] AllocArray<T>(int n1, int n2)
+ {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i)
+ {
+ a[i] = new T[n2];
+ }
+ return a;
+ }
+
+ private static
+ void BenchInner1(int[][] a, ref int nn)
+ {
+ int n;
+ int l, m;
+ n = nn;
+ for (int i = 1; i <= n; i++)
+ {
+ for (int j = (i + 1); j <= n; j++)
+ {
+ for (int k = 1; k <= n; k++)
+ {
+ l = a[i][k];
+ m = a[j][k];
+ unchecked
+ {
+ a[j][k] = l + m;
+ }
+ }
+ }
+ }
+ }
+
+ private static
+ void BenchInner2(int[][] a, ref int nn)
+ {
+ int n;
+ int l, m;
+ n = nn;
+ for (int i = 1; i <= n; i++)
+ {
+ for (int j = (i + 1); j <= n; j++)
+ {
+ for (int k = 1; k <= n; k++)
+ {
+ l = a[k][i];
+ m = a[k][j];
+ unchecked
+ {
+ a[k][j] = l + m;
+ }
+ }
+ }
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench(int[][] a)
+ {
+ int n = Dim;
+ for (int i = 1; i <= n; i++)
+ {
+ for (int j = 1; j <= n; j++)
+ {
+ a[i][j] = i + j;
+ }
+ }
+
+ BenchInner1(a, ref n);
+ n = Dim;
+ BenchInner2(a, ref n);
+
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ int[][] array = AllocArray<int>(Dim + 1, Dim + 1);
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ for (int i = 1; i <= Iterations; i++)
+ {
+ Bench(array);
+ }
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ int[][] array = AllocArray<int>(Dim + 1, Dim + 1);
+ bool result = true;
+ for (int i = 1; i <= Iterations; i++)
+ {
+ result &= Bench(array);
+ }
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AddArray2.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// The sorting benchmark calls a random number generator the number
+// of times specified by Maxnum to create an array of int integers,
+// then does a quicksort on the array of ints. Random numbers
+// are produced using a multiplicative modulus method with known
+// seed, so that the generated array is constant across compilers.
+//
+// This is adapted from a benchmark in BYTE Magazine, August 1984.
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class Array1
+{
+#if DEBUG
+ private const int Iterations = 1;
+ private const int Maxnum = 100;
+#else
+ private const int Iterations = 125;
+ private const int Maxnum = 1000;
+#endif
+
+ private const int Modulus = ((int)0x20000);
+ private const int C = 13849;
+ private const int A = 25173;
+ static int s_seed = 7;
+
+ private static void Quick(int lo, int hi, int[] input)
+ {
+ int i, j;
+ int pivot, temp;
+
+ if (lo < hi)
+ {
+ // 0 <= lo < hi
+ for (i = lo, j = (hi + 1), pivot = input[lo]; ;)
+ {
+ do
+ {
+ ++i;
+ } while (input[i] < pivot);
+
+ do
+ {
+ --j;
+ // Accessing upto hi
+ } while (input[j] > pivot);
+
+ if (i < j)
+ {
+ temp = input[i];
+ input[i] = input[j];
+ input[j] = temp;
+ }
+ else
+ {
+ break;
+ }
+ }
+ temp = input[j];
+ input[j] = input[lo];
+ input[lo] = temp;
+ Quick(lo, j - 1, input);
+ Quick(j + 1, hi, input);
+ }
+ }
+
+ private static int Random(int size)
+ {
+ unchecked
+ {
+ s_seed = s_seed * A + C;
+ }
+
+ return (s_seed % size);
+ }
+
+ private static bool VerifySort(int[] buffer)
+ {
+ for (int y = 0; y < Maxnum - 2; y++)
+ {
+ if (buffer[y] > buffer[y + 1])
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ int[] buffer = new int[Maxnum + 1];
+
+ for (int i = 0; i < Iterations; ++i)
+ {
+ for (int j = 0; j < Maxnum; ++j)
+ {
+ int temp = Random(Modulus);
+ if (temp < 0L)
+ {
+ temp = (-temp);
+ }
+ buffer[j] = temp;
+ }
+ buffer[Maxnum] = Modulus;
+
+ Quick(0, Maxnum - 1, buffer);
+ }
+
+ bool result = VerifySort(buffer);
+
+ return result;
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ for (int i = 0; i < Iterations; i++)
+ {
+ Bench();
+ }
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = true;
+ for (int i = 0; i < Iterations; i++)
+ {
+ result &= Bench();
+ }
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Array1.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class Array2
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 500000;
+#endif
+
+ static T[][][] AllocArray<T>(int n1, int n2, int n3) {
+ T[][][] a = new T[n1][][];
+ for (int i = 0; i < n1; ++i) {
+ a[i] = new T[n2][];
+ for (int j = 0; j < n2; j++) {
+ a[i][j] = new T[n3];
+ }
+ }
+
+ return a;
+ }
+
+ static void Initialize(int[][][] s) {
+ for (int i = 0; i < 10; i++) {
+ for (int j = 0; j < 10; j++) {
+ for (int k = 0; k < 10; k++) {
+ s[i][j][k] = (2 * i) - (3 * j) + (5 * k);
+ }
+ }
+ }
+ }
+
+ static bool VerifyCopy(int[][][] s, int[][][] d) {
+ for (int i = 0; i < 10; i++) {
+ for (int j = 0; j < 10; j++) {
+ for (int k = 0; k < 10; k++) {
+ if (s[i][j][k] != d[i][j][k]) {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench(int loop) {
+
+ int[][][] s = AllocArray<int>(10, 10, 10);
+ int[][][] d = AllocArray<int>(10, 10, 10);
+
+ Initialize(s);
+
+ for (; loop != 0; loop--) {
+ for (int i = 0; i < 10; i++) {
+ for (int j = 0; j < 10; j++) {
+ for (int k = 0; k < 10; k++) {
+ d[i][j][k] = s[i][j][k];
+ }
+ }
+ }
+ }
+
+ bool result = VerifyCopy(s, d);
+
+ return result;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ Bench(Iterations);
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = Bench(Iterations);
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Array2.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class BenchE
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 5000000;
+#endif
+
+ private static int s_position;
+
+ private static int Strsch(char[] s, char[] k, int ns, int nk)
+ {
+ int i, j;
+ int start, ksave, cont;
+ int kend, ssave;
+ int r;
+
+ start = 0;
+ ksave = 0;
+ cont = ns - nk + start;
+ kend = ksave + nk - 1;
+ i = 0;
+ j = 0;
+ top:
+ while (s[i] != k[j])
+ {
+ // s is accessed upto cont i.e. ns - nk + 0
+ if (i >= cont)
+ {
+ r = -1;
+ goto bottom;
+ }
+ i = i + 1;
+ }
+ ssave = i;
+ j = j + 1;
+ while (j <= kend)
+ {
+ i = i + 1;
+ // j <= kend, so k is accessed upto 0 + nk - 1
+ if (s[i] != k[j])
+ {
+ i = ssave + 1;
+ j = ksave;
+ goto top;
+ }
+ j = j + 1;
+ }
+ r = ssave - start + 1;
+ bottom:
+ return r;
+ }
+
+ private static void BenchInner(char[] s, char[] k)
+ {
+ int ns, nk;
+
+ ns = 120;
+ nk = 15;
+ s_position = Strsch(s, k, ns, nk);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool Bench()
+ {
+ char[] s = {
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'H', 'E', 'R', 'E', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ 'H', 'E', 'R', 'E', ' ', 'I', 'S', ' ', 'A', ' ', 'M', 'A', 'T', 'C', 'H', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'
+ };
+
+ char[] k = { 'H', 'E', 'R', 'E', ' ', 'I', 'S', ' ', 'A', ' ', 'M', 'A', 'T', 'C', 'H', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' };
+
+ for (int i = 0; i < Iterations; i++)
+ {
+ BenchInner(s, k);
+ }
+
+ return (s_position == 91);
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="BenchE.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class BubbleSort
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 55000;
+#endif
+
+ static void SortArray(int[] tab, int last) {
+ bool swap;
+ int temp;
+ do {
+ swap = false;
+ for (int i = 0; i < last; i++) {
+ if (tab[i] > tab[i + 1]) {
+ temp = tab[i];
+ tab[i] = tab[i + 1];
+ tab[i + 1] = temp;
+ swap = true;
+ }
+ }
+ }
+ while (swap);
+ }
+
+ static bool VerifySort(int[] tab, int last) {
+ for (int i = 0; i < last; i++) {
+ if (tab[i] > tab[i + 1]) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static public bool Bench() {
+ int[] tab = new int[100];
+ int k = 0;
+ for (int i = 9; i >= 0; i--) {
+ for (int j = i * 10; j < (i + 1) * 10; j++) {
+ tab[k++] = ((j & 1) == 1) ? j + 1 : j - 1;
+ }
+ }
+ SortArray(tab, 99);
+ bool result = VerifySort(tab, 99);
+ return result;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench();
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = true;
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench();
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="BubbleSort.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class BubbleSort2
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+ public const int Bound = 5 * Iterations;
+#else
+ public const int Iterations = 15;
+ public const int Bound = 500 * Iterations;
+#endif
+
+ static void Inner(int[] x) {
+ int limit1 = Bound - 1;
+ for (int i = 1; i <= limit1; i++) {
+ for (int j = i; j <= Bound; j++) {
+ if (x[i] > x[j]) {
+ int temp = x[j];
+ x[j] = x[i];
+ x[i] = temp;
+ }
+ }
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ int[] x = new int[Bound + 1];
+ int i, j;
+ int limit;
+ j = 99999;
+ limit = Bound - 2;
+ i = 1;
+ do {
+ x[i] = j & 32767;
+ x[i + 1] = (j + 11111) & 32767;
+ x[i + 2] = (j + 22222) & 32767;
+ j = j + 33333;
+ i = i + 3;
+ } while (i <= limit);
+ x[Bound - 1] = j;
+ x[Bound] = j;
+
+ Inner(x);
+
+ for (i = 0; i < Bound - 1; i++) {
+ if (x[i] > x[i + 1]) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench();
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = true;
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench();
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="BubbleSort2.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// Based on Eratosthenes Sieve Prime Number Program in C, Byte Magazine, January 1983.
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class CSieve
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 200;
+#endif
+
+ const int Size = 8190;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ bool[] flags = new bool[Size + 1];
+ int count = 0;
+ for (int iter = 1; iter <= Iterations; iter++)
+ {
+ count = 0;
+
+ // Initially, assume all are prime
+ for (int i = 0; i <= Size; i++)
+ {
+ flags[i] = true;
+ }
+
+ // Refine
+ for (int i = 2; i <= Size; i++)
+ {
+ if (flags[i])
+ {
+ // Found a prime
+ for (int k = i + i; k <= Size; k += i)
+ {
+ // Cancel its multiples
+ flags[k] = false;
+ }
+ count++;
+ }
+ }
+ }
+
+ return (count == 1027);
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench();
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = true;
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench();
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CSieve.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class Fib
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 3500;
+#endif
+
+ const int Number = 24;
+
+ static int Fibonacci(int x) {
+ if (x > 2) {
+ return (Fibonacci(x - 1) + Fibonacci(x - 2));
+ }
+ else {
+ return 1;
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ int fib = Fibonacci(Number);
+ return (fib == 46368);
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench();
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = true;
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench();
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Fib.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class HeapSort
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 2500;
+#endif
+
+ const int ArraySize = 5500;
+
+ static void Inner(int[] x, int n) {
+ int i, j, k, m;
+
+ // pass1 -- put vector in heap form
+ // that is to say, guarantee that x(i)>=x(2*i) and x(i)>=x(2*i+1).
+ // after pass 1, the largest item will be at x(1).
+ for (i = 2; i <= n; i++) {
+ j = i;
+ k = j / 2;
+ m = x[i];
+
+ // 0 < k <= (n / 2)
+ // 1 <= j <= n
+ while (k > 0) {
+ if (m <= x[k]) {
+ break;
+ }
+ x[j] = x[k];
+ j = k;
+ k = k / 2;
+ }
+ x[j] = m;
+ }
+
+ // pass 2 -- swap first and last items. now with the last
+ // item correctly placed, consider the list shorter by one item.
+ // restore the shortened list to heap sort, and repeat
+ // process until list is only two items long.
+ i = n;
+ do {
+ // do i = n to 2 by -1;
+ m = x[i];
+ x[i] = x[1]; // last item, i.e. item(i) now correct.
+ j = 1; // we now find the appropriate resting point for m
+ k = 2;
+
+ // 2 <= k < i ==> 2 <= k < n
+ // 1 <= j < n
+ while (k < i) {
+ if ((k + 1) < i) {
+ if (x[k + 1] > x[k]) {
+ k = k + 1;
+ }
+ }
+ if (x[k] <= m) {
+ break;
+ }
+
+ x[j] = x[k];
+ j = k;
+ k = k + k;
+ }
+
+ x[j] = m;
+ i = i - 1;
+ } while (i >= 2);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ int[] x = new int[ArraySize + 1];
+ for (int i = 1; i <= ArraySize; i++) {
+ x[i] = ArraySize - i + 1;
+ }
+ Inner(x, ArraySize);
+ for (int j = 1; j <= ArraySize; j++) {
+ if (x[j] != j) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench();
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = true;
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench();
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="HeapSort.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class IniArray
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 10000000;
+#endif
+
+ const int Allotted = 16;
+ static volatile object VolatileObject;
+
+ static void Escape(object obj) {
+ VolatileObject = obj;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ char[] workarea = new char[Allotted];
+ for (int i = 0; i < Iterations; i++) {
+ for (int j = 0; j < Allotted; j++) {
+ workarea[j] = ' ';
+ }
+ }
+ Escape(workarea);
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ Bench();
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="IniArray.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class LogicArray
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 3000;
+#endif
+
+ const int ArraySize = 50;
+
+ struct Workarea
+ {
+ public int X;
+ public int[][] A;
+ }
+
+ static T[][] AllocArray<T>(int n1, int n2) {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i) {
+ a[i] = new T[n2];
+ }
+ return a;
+ }
+
+ static bool Inner(ref Workarea cmn) {
+ int i, j, k;
+ cmn.X = 0;
+ for (i = 1; i <= 50; i++) {
+ for (j = 1; j <= 50; j++) {
+ cmn.A[i][j] = 1;
+ }
+ }
+ for (k = 1; k <= 50; k++) {
+ for (j = 1; j <= 50; j++) {
+ i = 1;
+ do {
+ cmn.X = cmn.X | cmn.A[i][j] & cmn.A[i + 1][k];
+ i = i + 2;
+ } while (i <= 50);
+ }
+ }
+ if (cmn.X != 1) {
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ Workarea cmn = new Workarea();
+ cmn.X = 0;
+ cmn.A = AllocArray<int>(51, 51);
+ for (int n = 1; n <= Iterations; n++) {
+ bool result = Inner(ref cmn);
+ if (!result) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ Bench();
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="LogicArray.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class Midpoint
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 70000;
+#endif
+
+ static T[][] AllocArray<T>(int n1, int n2) {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i) {
+ a[i] = new T[n2];
+ }
+ return a;
+ }
+
+ static int Inner(ref int x, ref int y, ref int z) {
+ int mid;
+
+ if (x < y) {
+ if (y < z) {
+ mid = y;
+ }
+ else {
+ if (x < z) {
+ mid = z;
+ }
+ else {
+ mid = x;
+ }
+ }
+ }
+ else {
+ if (x < z) {
+ mid = x;
+ }
+ else {
+ if (y < z) {
+ mid = z;
+ }
+ else {
+ mid = y;
+ }
+ }
+ }
+
+ return (mid);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ int[][] a = AllocArray<int>(2001, 4);
+ int[] mid = new int[2001];
+ int j = 99999;
+
+ for (int i = 1; i <= 2000; i++) {
+ a[i][1] = j & 32767;
+ a[i][2] = (j + 11111) & 32767;
+ a[i][3] = (j + 22222) & 32767;
+ j = j + 33333;
+ }
+
+ for (int k = 1; k <= Iterations; k++) {
+ for (int l = 1; l <= 2000; l++) {
+ mid[l] = Inner(ref a[l][1], ref a[l][2], ref a[l][3]);
+ }
+ }
+
+ return (mid[2000] == 17018);
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ Bench();
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Midpoint.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class MulMatrix
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 100;
+#endif
+
+ const int Size = 75;
+ static volatile object VolatileObject;
+
+ static void Escape(object obj) {
+ VolatileObject = obj;
+ }
+
+ static T[][] AllocArray<T>(int n1, int n2) {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i) {
+ a[i] = new T[n2];
+ }
+ return a;
+ }
+
+ static void Inner(int[][] a, int[][] b, int[][] c) {
+
+ int i, j, k, l;
+
+ // setup
+ for (j = 0; j < Size; j++) {
+ for (i = 0; i < Size; i++) {
+ a[i][j] = i;
+ b[i][j] = 2 * j;
+ c[i][j] = a[i][j] + b[i][j];
+ }
+ }
+
+ // jkl
+ for (j = 0; j < Size; j++) {
+ for (k = 0; k < Size; k++) {
+ for (l = 0; l < Size; l++) {
+ c[j][k] += a[j][l] * b[l][k];
+ }
+ }
+ }
+
+ // jlk
+ for (j = 0; j < Size; j++) {
+ for (l = 0; l < Size; l++) {
+ for (k = 0; k < Size; k++) {
+ c[j][k] += a[j][l] * b[l][k];
+ }
+ }
+ }
+
+ // kjl
+ for (k = 0; k < Size; k++) {
+ for (j = 0; j < Size; j++) {
+ for (l = 0; l < Size; l++) {
+ c[j][k] += a[j][l] * b[l][k];
+ }
+ }
+ }
+
+ // klj
+ for (k = 0; k < Size; k++) {
+ for (l = 0; l < Size; l++) {
+ for (j = 0; j < Size; j++) {
+ c[j][k] += a[j][l] * b[l][k];
+ }
+ }
+ }
+
+ // ljk
+ for (l = 0; l < Size; l++) {
+ for (j = 0; j < Size; j++) {
+ for (k = 0; k < Size; k++) {
+ c[j][k] += a[j][l] * b[l][k];
+ }
+ }
+ }
+
+ // lkj
+ for (l = 0; l < Size; l++) {
+ for (k = 0; k < Size; k++) {
+ for (j = 0; j < Size; j++) {
+ c[j][k] += a[j][l] * b[l][k];
+ }
+ }
+ }
+
+ return;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ int[][] a = AllocArray<int>(Size, Size);
+ int[][] b = AllocArray<int>(Size, Size);
+ int[][] c = AllocArray<int>(Size, Size);
+
+ for (int i = 0; i < Iterations; ++i) {
+ Inner(a, b, c);
+ }
+
+ Escape(c);
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ Bench();
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="MulMatrix.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// Adapted from
+//
+// Dhrystone: a synthetic systems programming benchmark
+// Reinhold P. Weicker
+// Communications of the ACM, Volume 27 Issue 10, Oct 1984, Pages 1013-1030
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class NDhrystone
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 7000000;
+#endif
+
+ static T[][] AllocArray<T>(int n1, int n2) {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i) {
+ a[i] = new T[n2];
+ }
+ return a;
+ }
+
+ enum Enumeration
+ {
+ Ident1 = 1, Ident2, Ident3, Ident4, Ident5
+ }
+
+ sealed class Record
+ {
+ public Record PtrComp;
+ public Enumeration Discr;
+ public Enumeration EnumComp;
+ public int IntComp;
+ public char[] StringComp;
+ }
+
+ static int s_intGlob;
+ static bool s_boolGlob;
+ static char s_char1Glob;
+ static char s_char2Glob;
+ static int[] m_array1Glob = new int[51];
+ static int[][] m_array2Glob;
+ static Record m_ptrGlb = new Record();
+ static Record m_ptrGlbNext = new Record();
+ static char[] m_string1Loc;
+ static char[] m_string2Loc;
+
+ static void Proc0() {
+ int intLoc1;
+ int intLoc2;
+ int intLoc3 = 0;
+ Enumeration enumLoc;
+
+ int i; /* modification */
+
+ m_ptrGlb.PtrComp = m_ptrGlbNext;
+ m_ptrGlb.Discr = Enumeration.Ident1;
+ m_ptrGlb.EnumComp = Enumeration.Ident3;
+ m_ptrGlb.IntComp = 40;
+ m_ptrGlb.StringComp = "DHRYSTONE PROGRAM, SOME STRING".ToCharArray();
+ m_string1Loc = "DHRYSTONE PROGRAM, 1'ST STRING".ToCharArray();
+ m_array2Glob[8][7] = 10; /* Was missing in published program */
+
+ for (i = 0; i < Iterations; ++i) {
+ Proc5();
+ Proc4();
+ intLoc1 = 2;
+ intLoc2 = 3;
+ m_string2Loc = "DHRYSTONE PROGRAM, 2'ND STRING".ToCharArray();
+ enumLoc = Enumeration.Ident2;
+ s_boolGlob = !Func2(m_string1Loc, m_string2Loc);
+ while (intLoc1 < intLoc2) {
+ intLoc3 = 5 * intLoc1 - intLoc2;
+ Proc7(intLoc1, intLoc2, ref intLoc3);
+ ++intLoc1;
+ }
+ Proc8(m_array1Glob, m_array2Glob, intLoc1, intLoc3);
+ Proc1(ref m_ptrGlb);
+ for (char charIndex = 'A'; charIndex <= s_char2Glob; ++charIndex) {
+ if (enumLoc == Func1(charIndex, 'C')) {
+ Proc6(Enumeration.Ident1, ref enumLoc);
+ }
+ }
+ intLoc3 = intLoc2 * intLoc1;
+ intLoc2 = intLoc3 / intLoc1;
+ intLoc2 = 7 * (intLoc3 - intLoc2) - intLoc1;
+ Proc2(ref intLoc1);
+ }
+ }
+
+ static void Proc1(ref Record ptrParIn) {
+ ptrParIn.PtrComp = m_ptrGlb;
+ ptrParIn.IntComp = 5;
+ ptrParIn.PtrComp.IntComp = ptrParIn.IntComp;
+ ptrParIn.PtrComp.PtrComp = ptrParIn.PtrComp;
+ Proc3(ref ptrParIn.PtrComp.PtrComp);
+ if (ptrParIn.PtrComp.Discr == Enumeration.Ident1) {
+ ptrParIn.PtrComp.IntComp = 6;
+ Proc6(ptrParIn.EnumComp, ref ptrParIn.PtrComp.EnumComp);
+ ptrParIn.PtrComp.PtrComp = m_ptrGlb.PtrComp;
+ Proc7(ptrParIn.PtrComp.IntComp, 10, ref ptrParIn.PtrComp.IntComp);
+ }
+ else {
+ ptrParIn = ptrParIn.PtrComp;
+ }
+ }
+
+ static void Proc2(ref int intParIO) {
+ int intLoc;
+ Enumeration enumLoc = Enumeration.Ident2;
+ intLoc = intParIO + 10;
+
+ for (;;) {
+ if (s_char1Glob == 'A') {
+ --intLoc;
+ intParIO = intLoc - s_intGlob;
+ enumLoc = Enumeration.Ident1;
+ }
+ if (enumLoc == Enumeration.Ident1) {
+ break;
+ }
+ }
+ }
+
+ static void Proc3(ref Record ptrParOut) {
+ if (m_ptrGlb != null) {
+ ptrParOut = m_ptrGlb.PtrComp;
+ }
+ else {
+ s_intGlob = 100;
+ }
+
+ Proc7(10, s_intGlob, ref m_ptrGlb.IntComp);
+ }
+
+ static void Proc4() {
+ bool boolLoc;
+ boolLoc = s_char1Glob == 'A';
+ boolLoc |= s_boolGlob;
+ s_char2Glob = 'B';
+ }
+
+ static void Proc5() {
+ s_char1Glob = 'A';
+ s_boolGlob = false;
+ }
+
+ static void Proc6(Enumeration enumParIn, ref Enumeration enumParOut) {
+ enumParOut = enumParIn;
+ if (!Func3(enumParIn)) {
+ enumParOut = Enumeration.Ident4;
+ }
+
+ switch (enumParIn) {
+ case Enumeration.Ident1:
+ enumParOut = Enumeration.Ident1;
+ break;
+ case Enumeration.Ident2:
+ if (s_intGlob > 100) {
+ enumParOut = Enumeration.Ident1;
+ }
+ else {
+ enumParOut = Enumeration.Ident4;
+ }
+ break;
+ case Enumeration.Ident3:
+ enumParOut = Enumeration.Ident2;
+ break;
+ case Enumeration.Ident4:
+ break;
+ case Enumeration.Ident5:
+ enumParOut = Enumeration.Ident3;
+ break;
+ }
+ }
+
+ static void Proc7(int intParI1, int intParI2, ref int intParOut) {
+ int intLoc;
+ intLoc = intParI1 + 2;
+ intParOut = intParI2 + intLoc;
+ }
+
+ static void Proc8(int[] array1Par, int[][] array2Par, int intParI1, int intParI2) {
+ int intLoc;
+ intLoc = intParI1 + 5;
+ array1Par[intLoc] = intParI2;
+ array1Par[intLoc + 1] = array1Par[intLoc];
+ array1Par[intLoc + 30] = intLoc;
+ for (int intIndex = intLoc; intIndex <= (intLoc + 1); ++intIndex) {
+ array2Par[intLoc][intIndex] = intLoc;
+ }
+ ++array2Par[intLoc][intLoc - 1];
+ array2Par[intLoc + 20][intLoc] = array1Par[intLoc];
+ s_intGlob = 5;
+ }
+
+ static Enumeration Func1(char charPar1, char charPar2) {
+ char charLoc1;
+ char charLoc2;
+ charLoc1 = charPar1;
+ charLoc2 = charLoc1;
+ if (charLoc2 != charPar2) {
+ return (Enumeration.Ident1);
+ }
+ else {
+ return (Enumeration.Ident2);
+ }
+ }
+
+ static bool Func2(char[] strParI1, char[] strParI2) {
+ int intLoc;
+ char charLoc = '\0';
+ intLoc = 1;
+ while (intLoc <= 1) {
+ if (Func1(strParI1[intLoc], strParI2[intLoc + 1]) == Enumeration.Ident1) {
+ charLoc = 'A';
+ ++intLoc;
+ }
+ }
+ if (charLoc >= 'W' && charLoc <= 'Z') {
+ intLoc = 7;
+ }
+ if (charLoc == 'X') {
+ return true;
+ }
+ else {
+ for (int i = 0; i < 30; i++) {
+ if (strParI1[i] > strParI2[i]) {
+ intLoc += 7;
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+
+ static bool Func3(Enumeration enumParIn) {
+ Enumeration enumLoc;
+ enumLoc = enumParIn;
+ if (enumLoc == Enumeration.Ident3) {
+ return true;
+ }
+
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ m_array2Glob = AllocArray<int>(51, 51);
+ Proc0();
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ Bench();
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = Bench();
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="NDhrystone.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public class Permutate
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 20000;
+#endif
+
+ private int[] _permArray = new int[11];
+ private static int s_pctr;
+
+ private static
+ void Swap(int[] arr, int i, int j)
+ {
+ int t = arr[i];
+ arr[i] = arr[j];
+ arr[j] = t;
+ }
+
+ private void Initialize()
+ {
+ for (int i = 1; i <= 7; i++)
+ {
+ _permArray[i] = i - 1;
+ }
+ }
+
+ private void PermuteArray(int n)
+ {
+ int k;
+ s_pctr = s_pctr + 1;
+ if (n != 1)
+ {
+ PermuteArray(n - 1);
+ for (k = n - 1; k >= 1; k--)
+ {
+ Swap(_permArray, n, k);
+ PermuteArray(n - 1);
+ Swap(_permArray, n, k);
+ }
+ }
+ }
+
+ private bool Validate()
+ {
+ int k = 0;
+
+ for (int i = 0; i <= 6; i++)
+ {
+ for (int j = 1; j <= 7; j++)
+ {
+ if (_permArray[j] == i)
+ {
+ k = k + 1;
+ }
+ }
+ }
+
+ return (k == 7);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private bool Bench()
+ {
+ Initialize();
+
+ for (int i = 0; i < Iterations; ++i)
+ {
+ s_pctr = 0;
+ PermuteArray(7);
+ }
+
+ bool result = Validate();
+
+ return result;
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ Permutate P = new Permutate();
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ P.Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ Permutate P = new Permutate();
+ bool result = P.Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Permutate.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class Pi
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 100;
+#endif
+
+ static int[] ComputePi(int[] a) {
+
+ int d = 4;
+ int r = 10000;
+ int n = 251;
+ int m = (int)(3.322 * n * d);
+ int[] digits = new int[n];
+ int i, k, q;
+
+ for (i = 0; i <= m; i++) {
+ a[i] = 2;
+ }
+
+ a[m] = 4;
+
+ for (i = 1; i <= n; i++) {
+ q = 0;
+ for (k = m; k > 0L; k--) {
+ a[k] = a[k] * r + q;
+ q = a[k] / (2 * k + 1);
+ a[k] -= (2 * k + 1) * q;
+ q *= k;
+ }
+ a[0] = a[0] * r + q;
+ q = a[0] / r;
+ a[0] -= q * r;
+ digits[i-1] = q;
+ }
+
+ return digits;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench(int[] a) {
+ int[] digits = ComputePi(a);
+ return (digits[0] == 3 && digits[1] == 1415 && digits[2] == 9265 && digits[250] == 1989);
+ }
+
+ [Benchmark]
+ public static void Test() {
+ int[] a = new int[3340];
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench(a);
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = true;
+ int[] a = new int[3340];
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench(a);
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Pi.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public class Puzzle
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 400;
+#endif
+
+ private const int PuzzleSize = 511;
+ private const int ClassMax = 3;
+ private const int TypeMax = 12;
+ private const int D = 8;
+
+ private int[] _pieceCount = new int[ClassMax + 1];
+ private int[] _class = new int[TypeMax + 1];
+ private int[] _pieceMax = new int[TypeMax + 1];
+ private bool[] _puzzle = new bool[PuzzleSize + 1];
+ private bool[][] _p;
+ private int _count;
+
+ private static T[][] AllocArray<T>(int n1, int n2)
+ {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i)
+ {
+ a[i] = new T[n2];
+ }
+
+ return a;
+ }
+
+ private bool Fit(int i, int j)
+ {
+ for (int k = 0; k <= _pieceMax[i]; k++)
+ {
+ if (_p[i][k])
+ {
+ if (_puzzle[j + k])
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private int Place(int i, int j)
+ {
+ int k;
+ for (k = 0; k <= _pieceMax[i]; k++)
+ {
+ if (_p[i][k])
+ {
+ _puzzle[j + k] = true;
+ }
+ }
+
+ _pieceCount[_class[i]] = _pieceCount[_class[i]] - 1;
+
+ for (k = j; k <= PuzzleSize; k++)
+ {
+ if (!_puzzle[k])
+ {
+ return k;
+ }
+ }
+
+ return 0;
+ }
+
+ private void RemoveLocal(int i, int j)
+ {
+ for (int k = 0; k <= _pieceMax[i]; k++)
+ {
+ if (_p[i][k])
+ {
+ _puzzle[j + k] = false;
+ }
+ }
+
+ _pieceCount[_class[i]] = _pieceCount[_class[i]] + 1;
+ }
+
+ private bool Trial(int j)
+ {
+ for (int i = 0; i <= TypeMax; i++)
+ {
+ if (_pieceCount[_class[i]] != 0)
+ {
+ if (Fit(i, j))
+ {
+ int k = Place(i, j);
+ if (Trial(k) || (k == 0))
+ {
+ _count = _count + 1;
+ return true;
+ }
+ else
+ {
+ RemoveLocal(i, j);
+ }
+ }
+ }
+ }
+
+ _count = _count + 1;
+ return false;
+ }
+
+ private bool DoIt()
+ {
+ int i, j, k, m, n;
+
+ for (m = 0; m <= PuzzleSize; m++)
+ {
+ _puzzle[m] = true;
+ }
+
+ for (i = 1; i <= 5; i++)
+ {
+ for (j = 1; j <= 5; j++)
+ {
+ for (k = 1; k <= 5; k++)
+ {
+ _puzzle[i + D * (j + D * k)] = false;
+ }
+ }
+ }
+
+ for (i = 0; i <= TypeMax; i++)
+ {
+ for (m = 0; m <= PuzzleSize; m++)
+ {
+ _p[i][m] = false;
+ }
+ }
+
+ for (i = 0; i <= 3; i++)
+ {
+ for (j = 0; j <= 1; j++)
+ {
+ for (k = 0; k <= 0; k++)
+ {
+ _p[0][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+
+ _class[0] = 0;
+ _pieceMax[0] = 3 + D * 1 + D * D * 0;
+
+ for (i = 0; i <= 1; i++)
+ {
+ for (j = 0; j <= 0; j++)
+ {
+ for (k = 0; k <= 3; k++)
+ {
+ _p[1][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+
+ _class[1] = 0;
+ _pieceMax[1] = 1 + D * 0 + D * D * 3;
+
+ for (i = 0; i <= 0; i++)
+ {
+ for (j = 0; j <= 3; j++)
+ {
+ for (k = 0; k <= 1; k++)
+ {
+ _p[2][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+ _class[2] = 0;
+ _pieceMax[2] = 0 + D * 3 + D * D * 1;
+
+ for (i = 0; i <= 1; i++)
+ {
+ for (j = 0; j <= 3; j++)
+ {
+ for (k = 0; k <= 0; k++)
+ {
+ _p[3][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+
+ _class[3] = 0;
+ _pieceMax[3] = 1 + D * 3 + D * D * 0;
+
+ for (i = 0; i <= 3; i++)
+ {
+ for (j = 0; j <= 0; j++)
+ {
+ for (k = 0; k <= 1; k++)
+ {
+ _p[4][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+
+ _class[4] = 0;
+ _pieceMax[4] = 3 + D * 0 + D * D * 1;
+
+ for (i = 0; i <= 0; i++)
+ {
+ for (j = 0; j <= 1; j++)
+ {
+ for (k = 0; k <= 3; k++)
+ {
+ _p[5][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+
+ _class[5] = 0;
+ _pieceMax[5] = 0 + D * 1 + D * D * 3;
+
+ for (i = 0; i <= 2; i++)
+ {
+ for (j = 0; j <= 0; j++)
+ {
+ for (k = 0; k <= 0; k++)
+ {
+ _p[6][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+
+ _class[6] = 1;
+ _pieceMax[6] = 2 + D * 0 + D * D * 0;
+
+ for (i = 0; i <= 0; i++)
+ {
+ for (j = 0; j <= 2; j++)
+ {
+ for (k = 0; k <= 0; k++)
+ {
+ _p[7][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+
+ _class[7] = 1;
+ _pieceMax[7] = 0 + D * 2 + D * D * 0;
+
+ for (i = 0; i <= 0; i++)
+ {
+ for (j = 0; j <= 0; j++)
+ {
+ for (k = 0; k <= 2; k++)
+ {
+ _p[8][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+
+ _class[8] = 1;
+ _pieceMax[8] = 0 + D * 0 + D * D * 2;
+
+ for (i = 0; i <= 1; i++)
+ {
+ for (j = 0; j <= 1; j++)
+ {
+ for (k = 0; k <= 0; k++)
+ {
+ _p[9][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+ _class[9] = 2;
+ _pieceMax[9] = 1 + D * 1 + D * D * 0;
+
+ for (i = 0; i <= 1; i++)
+ {
+ for (j = 0; j <= 0; j++)
+ {
+ for (k = 0; k <= 1; k++)
+ {
+ _p[10][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+
+ _class[10] = 2;
+ _pieceMax[10] = 1 + D * 0 + D * D * 1;
+
+ for (i = 0; i <= 0; i++)
+ {
+ for (j = 0; j <= 1; j++)
+ {
+ for (k = 0; k <= 1; k++)
+ {
+ _p[11][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+
+ _class[11] = 2;
+ _pieceMax[11] = 0 + D * 1 + D * D * 1;
+
+ for (i = 0; i <= 1; i++)
+ {
+ for (j = 0; j <= 1; j++)
+ {
+ for (k = 0; k <= 1; k++)
+ {
+ _p[12][i + D * (j + D * k)] = true;
+ }
+ }
+ }
+
+ _class[12] = 3;
+ _pieceMax[12] = 1 + D * 1 + D * D * 1;
+ _pieceCount[0] = 13;
+ _pieceCount[1] = 3;
+ _pieceCount[2] = 1;
+ _pieceCount[3] = 1;
+ m = 1 + D * (1 + D * 1);
+ _count = 0;
+
+ bool result = true;
+
+ if (Fit(0, m))
+ {
+ n = Place(0, m);
+ result = Trial(n);
+ }
+ else
+ {
+ result = false;
+ }
+
+ return result;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private bool Bench()
+ {
+ _p = AllocArray<bool>(TypeMax + 1, PuzzleSize + 1);
+
+ bool result = true;
+
+ for (int i = 0; i < Iterations; ++i)
+ {
+ result &= DoIt();
+ }
+
+ return result;
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ Puzzle P = new Puzzle();
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ P.Bench();
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ Puzzle P = new Puzzle();
+ bool result = P.Bench();
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Puzzle.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class QuickSort
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 80000;
+#endif
+
+ const int MAXNUM = 200;
+ const int MODULUS = 0x20000;
+ const int C = 13849;
+ const int A = 25173;
+ static int s_seed = 7;
+
+ static int Random(int size) {
+ unchecked {
+ s_seed = s_seed * A + C;
+ }
+ return (s_seed % size);
+ }
+
+ static void Quick(int lo, int hi, int[] arr) {
+
+ int i, j;
+ int pivot, temp;
+
+ if (lo < hi) {
+ for (i = lo, j = hi, pivot = arr[hi]; i < j;) {
+ while (i < j && arr[i] <= pivot){
+ ++i;
+ }
+ while (j > i && arr[j] >= pivot) {
+ --j;
+ }
+ if (i < j) {
+ temp = arr[i];
+ arr[i] = arr[j];
+ arr[j] = temp;
+ }
+ }
+
+ // need to swap the pivot and a[i](or a[j] as i==j) so
+ // that the pivot will be at its final place in the sorted array
+
+ if (i != hi) {
+ temp = arr[i];
+ arr[i] = pivot;
+ arr[hi] = temp;
+ }
+ Quick(lo, i - 1, arr);
+ Quick(i + 1, hi, arr);
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+
+ int[] buffer = new int[MAXNUM];
+
+ for (int j = 0; j < MAXNUM; ++j) {
+ int temp = Random(MODULUS);
+ if (temp < 0){
+ temp = (-temp);
+ }
+ buffer[j] = temp;
+ }
+
+ Quick(0, MAXNUM - 1, buffer);
+
+ for (int j = 0; j < MAXNUM - 1; ++j) {
+ if (buffer[j] > buffer[j+1]) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench();
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = true;
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench();
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="QuickSort.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public class TreeInsert
+{
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 15000;
+#endif
+
+ private struct Node
+ {
+ public int A;
+ public int L;
+ public int R;
+ }
+
+ private struct Tree
+ {
+ public int Root;
+ public int NextAvail;
+ public Node[] Nodes;
+ }
+
+ private Tree _s;
+
+ public TreeInsert()
+ {
+ _s.Nodes = new Node[10001];
+ }
+
+ private void BenchInner(int x)
+ {
+ /* a tree insertion routine from knuth */
+ int i = _s.Root;
+ int j = _s.NextAvail;
+
+ L10:
+ /* compare */
+ if (_s.Nodes[i].A < x)
+ {
+ if (_s.Nodes[i].L != 0)
+ {
+ i = _s.Nodes[i].L;
+ goto L10;
+ }
+ else
+ {
+ _s.Nodes[i].L = j;
+ goto L20;
+ }
+ }
+ else
+ {
+ if (_s.Nodes[i].R != 0)
+ {
+ i = _s.Nodes[i].R;
+ goto L10;
+ }
+ else
+ {
+ _s.Nodes[i].R = j;
+ goto L20;
+ }
+ }
+
+ L20:
+ /* insert */
+ _s.Nodes[j].A = x;
+ _s.Nodes[j].L = 0;
+ _s.Nodes[j].R = 0;
+ _s.NextAvail = j + 1;
+ }
+
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private bool Bench()
+ {
+ _s.Root = 1;
+ _s.NextAvail = 2;
+ _s.Nodes[1].A = 300;
+ _s.Nodes[1].L = 0;
+ _s.Nodes[1].R = 0;
+
+ int j = 99999;
+ for (int i = 1; i <= 900; i++)
+ {
+ BenchInner(j & 4095);
+ j = j + 33333;
+ }
+
+ return (_s.Nodes[500].A == 441);
+ }
+
+ [Benchmark]
+ public static void Test()
+ {
+ TreeInsert T = new TreeInsert();
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ for (int i = 1; i <= Iterations; i++)
+ {
+ T.Bench();
+ }
+ }
+ }
+ }
+
+ private static bool TestBase()
+ {
+ TreeInsert T = new TreeInsert();
+ bool result = true;
+ for (int i = 1; i <= Iterations; i++)
+ {
+ result &= T.Bench();
+ }
+ return result;
+ }
+
+ public static int Main()
+ {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="TreeInsert.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class TreeSort
+{
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 1200;
+#endif
+
+ const int SortElements = 5000;
+ const int Modulus = 65536;
+
+ sealed class Node
+ {
+ public Node Left;
+ public Node Right;
+ public int Val;
+ public Node(int n)
+ {
+ Left = null;
+ Right = null;
+ Val = n;
+ }
+ }
+
+ static int s_biggest;
+ static int s_littlest;
+ static int s_seed;
+
+ static void InitRand() {
+ s_seed = 33;
+ }
+
+ static int Rand(ref int seed) {
+ int multiplier = 25173;
+ int increment = 13849;
+ seed = (multiplier * seed + increment) % Modulus;
+ return seed;
+ }
+
+ static void InitArray(int[] sortList) {
+ InitRand();
+ s_biggest = 0;
+ s_littlest = Modulus;
+ for (int i = 1; i <= SortElements; i++) {
+ sortList[i] = Rand(ref s_seed) - 1;
+ if (sortList[i] > s_biggest) {
+ s_biggest = sortList[i];
+ }
+ else if (sortList[i] < s_littlest) {
+ s_littlest = sortList[i];
+ }
+ }
+ }
+
+ static void Insert(int n, Node t) {
+ if (n > t.Val) {
+ if (t.Left == null) {
+ t.Left = new Node(n);
+ }
+ else {
+ Insert(n, t.Left);
+ }
+ }
+ else if (n < t.Val) {
+ if (t.Right == null) {
+ t.Right = new Node(n);
+ }
+ else {
+ Insert(n, t.Right);
+ }
+ }
+ }
+
+ static bool CheckTree(Node p) {
+ bool result = true;
+ if (p.Left != null) {
+ if (p.Left.Val <= p.Val) {
+ result = false;
+ }
+ else {
+ result &= CheckTree(p.Left);
+ }
+ }
+
+ if (p.Right != null) {
+ if (p.Right.Val >= p.Val) {
+ result = false;
+ }
+ else {
+ result &= CheckTree(p.Right);
+ }
+ }
+
+ return result;
+ }
+
+ static bool Trees(int[] sortList) {
+ InitArray(sortList);
+ Node tree = new Node(sortList[1]);
+ for (int i = 2; i <= SortElements; i++) {
+ Insert(sortList[i], tree);
+ }
+ bool result = CheckTree(tree);
+ return result;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench() {
+ int[] sortList = new int[SortElements + 1];
+ bool result = Trees(sortList);
+ return result;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench();
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ bool result = true;
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench();
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="TreeSort.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+[assembly: OptimizeForBenchmarks]
+
+namespace Benchstone.BenchI
+{
+public static class XposMatrix
+{
+ public const int ArraySize = 100;
+
+#if DEBUG
+ public const int Iterations = 1;
+#else
+ public const int Iterations = 25000;
+#endif
+
+ static T[][] AllocArray<T>(int n1, int n2) {
+ T[][] a = new T[n1][];
+ for (int i = 0; i < n1; ++i) {
+ a[i] = new T[n2];
+ }
+ return a;
+ }
+
+ static void Inner(int[][] x, int n) {
+ for (int i = 1; i <= n; i++) {
+ for (int j = 1; j <= n; j++) {
+ int t = x[i][j];
+ x[i][j] = x[j][i];
+ x[j][i] = t;
+ }
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Bench(int[][] matrix) {
+
+ int n = ArraySize;
+ for (int i = 1; i <= n; i++) {
+ for (int j = 1; j <= n; j++) {
+ matrix[i][j] = 1;
+ }
+ }
+
+ if (matrix[n][n] != 1) {
+ return false;
+ }
+
+ Inner(matrix, n);
+
+ if (matrix[n][n] != 1) {
+ return false;
+ }
+
+ return true;
+ }
+
+ [Benchmark]
+ public static void Test() {
+ int[][] matrix = AllocArray<int>(ArraySize + 1, ArraySize + 1);
+ foreach (var iteration in Benchmark.Iterations) {
+ using (iteration.StartMeasurement()) {
+ for (int i = 0; i < Iterations; i++) {
+ Bench(matrix);
+ }
+ }
+ }
+ }
+
+ static bool TestBase() {
+ int[][] matrix = AllocArray<int>(ArraySize + 1, ArraySize + 1);
+ bool result = true;
+ for (int i = 0; i < Iterations; i++) {
+ result &= Bench(matrix);
+ }
+ return result;
+ }
+
+ public static int Main() {
+ bool result = TestBase();
+ return (result ? 100 : -1);
+ }
+}
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker>
+ <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <PropertyGroup>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="XposMatrix.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+ <PropertyGroup>
+ <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark\obj\project.assets.json</ProjectAssetsFile>
+ </PropertyGroup>
+</Project>