summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm
diff options
context:
space:
mode:
authorJoseph Tremoulet <jotrem@microsoft.com>2017-09-14 15:23:20 -0400
committerJoseph Tremoulet <jotrem@microsoft.com>2017-09-15 13:46:59 -0400
commit9a8151fbddd80a845a655763106c792b8350bfac (patch)
tree1ebda9335effcaaf8c3fbf20bf60bc10a35c753c /tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm
parente05511683b49b798f30b2b9fcad01425d4ef5c31 (diff)
downloadcoreclr-9a8151fbddd80a845a655763106c792b8350bfac.tar.gz
coreclr-9a8151fbddd80a845a655763106c792b8350bfac.tar.bz2
coreclr-9a8151fbddd80a845a655763106c792b8350bfac.zip
Remove old versions of BenchmarksGame benchmarks
Diffstat (limited to 'tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm')
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.cs128
-rw-r--r--tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.csproj38
2 files changed, 0 insertions, 166 deletions
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.cs b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.cs
deleted file mode 100644
index 5f2b1aed5f..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-// 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 Computer Language Benchmarks Game
- http://benchmarksgame.alioth.debian.org/
-
- contributed by Isaac Gouy
-
- modified for use with xunit-performance
-*/
-
-using Microsoft.Xunit.Performance;
-using System;
-
-[assembly: OptimizeForBenchmarks]
-
-namespace BenchmarksGame
-{
-public class SpectralNorm
-{
-#if DEBUG
- public const int Iterations = 1;
-#else
- public const int Iterations = 300;
-#endif
-
- public static int Main(String[] args)
- {
- int n = 100;
- if (args.Length > 0) n = Int32.Parse(args[0]);
- double norm = new SpectralNorm().Approximate(n);
- Console.WriteLine("Norm={0:f9}", norm);
- double expected = 1.274219991;
- bool result = Math.Abs(norm - expected) < 1e-4;
- return (result ? 100 : -1);
- }
-
- [Benchmark]
- public static void Bench()
- {
- int n = 100;
- foreach (var iteration in Benchmark.Iterations)
- {
- double a = 0;
-
- using (iteration.StartMeasurement())
- {
- for (int i = 0; i < Iterations; i++)
- {
- SpectralNorm s = new SpectralNorm();
- a += s.Approximate(n);
- }
- }
-
- double norm = a / Iterations;
- double expected = 1.274219991;
- bool valid = Math.Abs(norm - expected) < 1e-4;
- if (!valid)
- {
- throw new Exception("Benchmark failed to validate");
- }
- }
- }
-
- private double Approximate(int n)
- {
- // create unit vector
- double[] u = new double[n];
- for (int i = 0; i < n; i++) u[i] = 1;
-
- // 20 steps of the power method
- double[] v = new double[n];
- for (int i = 0; i < n; i++) v[i] = 0;
-
- for (int i = 0; i < 10; i++)
- {
- MultiplyAtAv(n, u, v);
- MultiplyAtAv(n, v, u);
- }
-
- // B=AtA A multiplied by A transposed
- // v.Bv /(v.v) eigenvalue of v
- double vBv = 0, vv = 0;
- for (int i = 0; i < n; i++)
- {
- vBv += u[i] * v[i];
- vv += v[i] * v[i];
- }
-
- return Math.Sqrt(vBv / vv);
- }
-
-
- /* return element i,j of infinite matrix A */
- private double A(int i, int j)
- {
- return 1.0 / ((i + j) * (i + j + 1) / 2 + i + 1);
- }
-
- /* multiply vector v by matrix A */
- private void MultiplyAv(int n, double[] v, double[] Av)
- {
- for (int i = 0; i < n; i++)
- {
- Av[i] = 0;
- for (int j = 0; j < n; j++) Av[i] += A(i, j) * v[j];
- }
- }
-
- /* multiply vector v by matrix A transposed */
- private void MultiplyAtv(int n, double[] v, double[] Atv)
- {
- for (int i = 0; i < n; i++)
- {
- Atv[i] = 0;
- for (int j = 0; j < n; j++) Atv[i] += A(j, i) * v[j];
- }
- }
-
- /* multiply vector v by matrix A and then by matrix A transposed */
- private void MultiplyAtAv(int n, double[] v, double[] AtAv)
- {
- double[] u = new double[n];
- MultiplyAv(n, v, u);
- MultiplyAtv(n, u, AtAv);
- }
-}
-}
diff --git a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.csproj b/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.csproj
deleted file mode 100644
index 3c3e32e986..0000000000
--- a/tests/src/JIT/Performance/CodeQuality/BenchmarksGame/spectralnorm/spectralnorm.csproj
+++ /dev/null
@@ -1,38 +0,0 @@
-<?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="spectralnorm.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>