higherlogics_benchmarks

changeset 0:1e75a9fd032f

-added test program for thread-local storage
author Sandro Magi <naasking@gmail.com>
date Mon Sep 26 21:50:27 2011 -0400 (6 years ago)
parents
children 8c291eb6d1f3
files .hgignore TlsTests/TlsTests.sln TlsTests/TlsTests/Program.cs TlsTests/TlsTests/Properties/AssemblyInfo.cs TlsTests/TlsTests/TlsTests.csproj
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/.hgignore Mon Sep 26 21:50:27 2011 -0400 1.3 @@ -0,0 +1,4 @@ 1.4 +syntax: glob 1.5 +*.suo 1.6 +bin 1.7 +obj
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/TlsTests/TlsTests.sln Mon Sep 26 21:50:27 2011 -0400 2.3 @@ -0,0 +1,72 @@ 2.4 + 2.5 +Microsoft Visual Studio Solution File, Format Version 11.00 2.6 +# Visual Studio 2010 2.7 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TlsTests", "TlsTests\TlsTests.csproj", "{457CB470-D947-4AF0-8660-C4BAD42DF019}" 2.8 +EndProject 2.9 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sasa", "..\sasa\Sasa\Sasa.csproj", "{6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}" 2.10 +EndProject 2.11 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sasa.TM", "..\sasa\Sasa.TM\Sasa.TM.csproj", "{B530FE06-7643-4D63-B06D-CCAE19E96B34}" 2.12 +EndProject 2.13 +Global 2.14 + GlobalSection(SolutionConfigurationPlatforms) = preSolution 2.15 + Code coverage|Any CPU = Code coverage|Any CPU 2.16 + Code coverage|Mixed Platforms = Code coverage|Mixed Platforms 2.17 + Code coverage|x86 = Code coverage|x86 2.18 + Debug|Any CPU = Debug|Any CPU 2.19 + Debug|Mixed Platforms = Debug|Mixed Platforms 2.20 + Debug|x86 = Debug|x86 2.21 + Release|Any CPU = Release|Any CPU 2.22 + Release|Mixed Platforms = Release|Mixed Platforms 2.23 + Release|x86 = Release|x86 2.24 + EndGlobalSection 2.25 + GlobalSection(ProjectConfigurationPlatforms) = postSolution 2.26 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Code coverage|Any CPU.ActiveCfg = Release|x86 2.27 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Code coverage|Mixed Platforms.ActiveCfg = Release|x86 2.28 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Code coverage|Mixed Platforms.Build.0 = Release|x86 2.29 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Code coverage|x86.ActiveCfg = Release|x86 2.30 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Code coverage|x86.Build.0 = Release|x86 2.31 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Debug|Any CPU.ActiveCfg = Debug|x86 2.32 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 2.33 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Debug|Mixed Platforms.Build.0 = Debug|x86 2.34 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Debug|x86.ActiveCfg = Debug|x86 2.35 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Debug|x86.Build.0 = Debug|x86 2.36 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Release|Any CPU.ActiveCfg = Release|x86 2.37 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Release|Mixed Platforms.ActiveCfg = Release|x86 2.38 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Release|Mixed Platforms.Build.0 = Release|x86 2.39 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Release|x86.ActiveCfg = Release|x86 2.40 + {457CB470-D947-4AF0-8660-C4BAD42DF019}.Release|x86.Build.0 = Release|x86 2.41 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Code coverage|Any CPU.ActiveCfg = Code coverage|Any CPU 2.42 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Code coverage|Any CPU.Build.0 = Code coverage|Any CPU 2.43 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Code coverage|Mixed Platforms.ActiveCfg = Code coverage|Any CPU 2.44 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Code coverage|Mixed Platforms.Build.0 = Code coverage|Any CPU 2.45 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Code coverage|x86.ActiveCfg = Code coverage|Any CPU 2.46 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 2.47 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Debug|Any CPU.Build.0 = Debug|Any CPU 2.48 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 2.49 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 2.50 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Debug|x86.ActiveCfg = Debug|Any CPU 2.51 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Release|Any CPU.ActiveCfg = Release|Any CPU 2.52 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Release|Any CPU.Build.0 = Release|Any CPU 2.53 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 2.54 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Release|Mixed Platforms.Build.0 = Release|Any CPU 2.55 + {6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}.Release|x86.ActiveCfg = Release|Any CPU 2.56 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Code coverage|Any CPU.ActiveCfg = Release|Any CPU 2.57 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Code coverage|Any CPU.Build.0 = Release|Any CPU 2.58 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Code coverage|Mixed Platforms.ActiveCfg = Release|Any CPU 2.59 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Code coverage|Mixed Platforms.Build.0 = Release|Any CPU 2.60 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Code coverage|x86.ActiveCfg = Release|Any CPU 2.61 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 2.62 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Debug|Any CPU.Build.0 = Debug|Any CPU 2.63 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 2.64 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 2.65 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Debug|x86.ActiveCfg = Debug|Any CPU 2.66 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Release|Any CPU.ActiveCfg = Release|Any CPU 2.67 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Release|Any CPU.Build.0 = Release|Any CPU 2.68 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 2.69 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Release|Mixed Platforms.Build.0 = Release|Any CPU 2.70 + {B530FE06-7643-4D63-B06D-CCAE19E96B34}.Release|x86.ActiveCfg = Release|Any CPU 2.71 + EndGlobalSection 2.72 + GlobalSection(SolutionProperties) = preSolution 2.73 + HideSolutionNode = FALSE 2.74 + EndGlobalSection 2.75 +EndGlobal
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/TlsTests/TlsTests/Program.cs Mon Sep 26 21:50:27 2011 -0400 3.3 @@ -0,0 +1,53 @@ 3.4 +using System; 3.5 +using System.IO; 3.6 +using System.Collections.Generic; 3.7 +using System.Linq; 3.8 +using System.Diagnostics; 3.9 +using System.Threading; 3.10 +using Sasa; 3.11 +using Sasa.Concurrency; 3.12 + 3.13 +namespace TlsTests 3.14 +{ 3.15 + class Program 3.16 + { 3.17 + const int iterations = 100000000; 3.18 + static ThreadLocal<double> counter = new ThreadLocal<double>(); 3.19 + //static ThreadScoped<double> counter = ThreadScoped.Create<double>(); 3.20 + 3.21 + static void CountUp() 3.22 + { 3.23 + for (int i = 0; i < iterations; ++i) 3.24 + { 3.25 + counter.Value = Math.Sin((i % 360) * Math.PI); 3.26 + } 3.27 + } 3.28 + static void CountDown() 3.29 + { 3.30 + for (int i = iterations; i >= 0; --i) 3.31 + { 3.32 + counter.Value = Math.Sin((i % 360) * Math.PI); 3.33 + } 3.34 + } 3.35 + 3.36 + static void Main(string[] args) 3.37 + { 3.38 + var other = new Thread(CountUp); 3.39 + var clock = new Stopwatch(); 3.40 + clock.Start(); 3.41 + other.Start(); 3.42 + CountDown(); 3.43 + other.Join(); 3.44 + clock.Stop(); 3.45 + 3.46 + var throughput = 2 * 1000 * (iterations / clock.ElapsedMilliseconds); 3.47 + var hundreds = throughput % 1000; 3.48 + var thousands = (throughput % 1000000 - hundreds) / 1000; 3.49 + var millions = (throughput % 1000000000 - thousands) / 1000000; 3.50 + Console.WriteLine("{3}: {0:000},{1:000},{2:000} iterations/second", millions, thousands, hundreds, throughput); 3.51 + Console.WriteLine("output: {0}", counter.Value); 3.52 + File.AppendAllText("thread-local.csv", string.Format("{0}\r\n", throughput)); 3.53 + Console.ReadLine(); 3.54 + } 3.55 + } 3.56 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/TlsTests/TlsTests/Properties/AssemblyInfo.cs Mon Sep 26 21:50:27 2011 -0400 4.3 @@ -0,0 +1,36 @@ 4.4 +using System.Reflection; 4.5 +using System.Runtime.CompilerServices; 4.6 +using System.Runtime.InteropServices; 4.7 + 4.8 +// General Information about an assembly is controlled through the following 4.9 +// set of attributes. Change these attribute values to modify the information 4.10 +// associated with an assembly. 4.11 +[assembly: AssemblyTitle("TlsTests")] 4.12 +[assembly: AssemblyDescription("")] 4.13 +[assembly: AssemblyConfiguration("")] 4.14 +[assembly: AssemblyCompany("")] 4.15 +[assembly: AssemblyProduct("TlsTests")] 4.16 +[assembly: AssemblyCopyright("Copyright © 2011")] 4.17 +[assembly: AssemblyTrademark("")] 4.18 +[assembly: AssemblyCulture("")] 4.19 + 4.20 +// Setting ComVisible to false makes the types in this assembly not visible 4.21 +// to COM components. If you need to access a type in this assembly from 4.22 +// COM, set the ComVisible attribute to true on that type. 4.23 +[assembly: ComVisible(false)] 4.24 + 4.25 +// The following GUID is for the ID of the typelib if this project is exposed to COM 4.26 +[assembly: Guid("43a22869-d945-4b07-ad68-8ea3aa89593a")] 4.27 + 4.28 +// Version information for an assembly consists of the following four values: 4.29 +// 4.30 +// Major Version 4.31 +// Minor Version 4.32 +// Build Number 4.33 +// Revision 4.34 +// 4.35 +// You can specify all the values or you can default the Build and Revision Numbers 4.36 +// by using the '*' as shown below: 4.37 +// [assembly: AssemblyVersion("1.0.*")] 4.38 +[assembly: AssemblyVersion("1.0.0.0")] 4.39 +[assembly: AssemblyFileVersion("1.0.0.0")]
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/TlsTests/TlsTests/TlsTests.csproj Mon Sep 26 21:50:27 2011 -0400 5.3 @@ -0,0 +1,63 @@ 5.4 +<?xml version="1.0" encoding="utf-8"?> 5.5 +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 5.6 + <PropertyGroup> 5.7 + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 5.8 + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> 5.9 + <ProductVersion>8.0.30703</ProductVersion> 5.10 + <SchemaVersion>2.0</SchemaVersion> 5.11 + <ProjectGuid>{457CB470-D947-4AF0-8660-C4BAD42DF019}</ProjectGuid> 5.12 + <OutputType>Exe</OutputType> 5.13 + <AppDesignerFolder>Properties</AppDesignerFolder> 5.14 + <RootNamespace>TlsTests</RootNamespace> 5.15 + <AssemblyName>TlsTests</AssemblyName> 5.16 + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> 5.17 + <TargetFrameworkProfile>Client</TargetFrameworkProfile> 5.18 + <FileAlignment>512</FileAlignment> 5.19 + </PropertyGroup> 5.20 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> 5.21 + <PlatformTarget>x86</PlatformTarget> 5.22 + <DebugSymbols>true</DebugSymbols> 5.23 + <DebugType>full</DebugType> 5.24 + <Optimize>false</Optimize> 5.25 + <OutputPath>bin\Debug\</OutputPath> 5.26 + <DefineConstants>DEBUG;TRACE</DefineConstants> 5.27 + <ErrorReport>prompt</ErrorReport> 5.28 + <WarningLevel>4</WarningLevel> 5.29 + </PropertyGroup> 5.30 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> 5.31 + <PlatformTarget>x86</PlatformTarget> 5.32 + <DebugType>pdbonly</DebugType> 5.33 + <Optimize>true</Optimize> 5.34 + <OutputPath>bin\Release\</OutputPath> 5.35 + <DefineConstants>TRACE</DefineConstants> 5.36 + <ErrorReport>prompt</ErrorReport> 5.37 + <WarningLevel>4</WarningLevel> 5.38 + </PropertyGroup> 5.39 + <ItemGroup> 5.40 + <Reference Include="System" /> 5.41 + <Reference Include="System.Core" /> 5.42 + <Reference Include="Microsoft.CSharp" /> 5.43 + </ItemGroup> 5.44 + <ItemGroup> 5.45 + <Compile Include="Program.cs" /> 5.46 + <Compile Include="Properties\AssemblyInfo.cs" /> 5.47 + </ItemGroup> 5.48 + <ItemGroup> 5.49 + <ProjectReference Include="..\..\sasa\Sasa.TM\Sasa.TM.csproj"> 5.50 + <Project>{B530FE06-7643-4D63-B06D-CCAE19E96B34}</Project> 5.51 + <Name>Sasa.TM</Name> 5.52 + </ProjectReference> 5.53 + <ProjectReference Include="..\..\sasa\Sasa\Sasa.csproj"> 5.54 + <Project>{6B7E8BDE-CBFD-4A7D-90AA-0507DC060B11}</Project> 5.55 + <Name>Sasa</Name> 5.56 + </ProjectReference> 5.57 + </ItemGroup> 5.58 + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 5.59 + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 5.60 + Other similar extension points exist, see Microsoft.Common.targets. 5.61 + <Target Name="BeforeBuild"> 5.62 + </Target> 5.63 + <Target Name="AfterBuild"> 5.64 + </Target> 5.65 + --> 5.66 +</Project> 5.67 \ No newline at end of file