Permalink
Browse files

New runtime test project for data structures

  • Loading branch information...
1 parent 1fd6ab9 commit d221101e8f03f2324a07c9f81f072d0f153dd9fc @forki forki committed May 28, 2012
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
+ </startup>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="2.3.5.0" newVersion="4.3.0.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>c6835309-26a4-4718-931f-fd533e08e1d6</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>DataStructures</RootNamespace>
+ <AssemblyName>DataStructures</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <Name>DataStructures</Name>
+ <TargetFrameworkProfile>
+ </TargetFrameworkProfile>
+ <FscToolPath>..\..\lib\FSharp\</FscToolPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <Tailcalls>false</Tailcalls>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <Tailcalls>true</Tailcalls>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DataStructures|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <Tailcalls>false</Tailcalls>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <OutputPath>bin\DataStructures\</OutputPath>
+ </PropertyGroup>
+ <Import Project="..\..\lib\FSharp\Microsoft.FSharp.Targets" />
+ <ItemGroup>
+ <Compile Include="Program.fs" />
+ <None Include="App.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="FSharp.Core" Condition="$(TargetFrameworkVersion) == 'v3.5'">
+ <HintPath>..\..\lib\FSharp\Net20\FSharp.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="FSharp.Core" Condition="'$(TargetFrameworkVersion)' == 'v4.0'">
+ <HintPath>..\..\lib\FSharp\FSharp.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="FSharp.Core" Condition="'$(TargetFrameworkVersion)' == 'v4.5'">
+ <HintPath>..\..\lib\FSharp\Net45\FSharp.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="mscorlib" />
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\FSharpx.Core\FSharpx.Core.fsproj">
+ <Name>FSharpx.Core</Name>
+ <Project>{1e95a279-c2a9-498b-bc72-6e7a0d6854ce}</Project>
+ <Private>True</Private>
+ </ProjectReference>
+ </ItemGroup>
+</Project>
@@ -0,0 +1,18 @@
+<ProjectConfiguration>
+ <CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
+ <ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
+ <AllowCodeContractChecking>false</AllowCodeContractChecking>
+ <IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
+ <RunPreBuildEvents>false</RunPreBuildEvents>
+ <RunPostBuildEvents>false</RunPostBuildEvents>
+ <PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
+ <InstrumentAssembly>true</InstrumentAssembly>
+ <PreventSigningOfAssembly>false</PreventSigningOfAssembly>
+ <AnalyseExecutionTimes>true</AnalyseExecutionTimes>
+ <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
+ <DefaultTestTimeout>60000</DefaultTestTimeout>
+ <UseBuildConfiguration></UseBuildConfiguration>
+ <ProxyProcessPath></ProxyProcessPath>
+ <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
+ <AdditionalFilesToInclude>..\..\lib\FSharp\*.dll;..\..\lib\FSharp\*.exe</AdditionalFilesToInclude>
+</ProjectConfiguration>
@@ -0,0 +1,56 @@
+let c = 5
+let r = new System.Random()
+
+open FSharpx.TimeMeasurement
+open FSharpx.DataStructures.PersistentVector
+
+let array n = [|for i in 1..n -> r.Next()|]
+
+let vector n =
+ let v = ref empty
+ for i in 1..n do
+ v := cons (r.Next()) !v
+ !v
+
+let initArrayAndVector n =
+ printfn "Init with n = %d" n
+
+ compareTwoRuntimes c
+ " Array" (fun () -> array n)
+ " PersistentVector" (fun () -> vector n)
+
+let lookupInArrayAndVector n count =
+ printfn "%d Lookups in size n = %d" count n
+ let array = array n
+ let vector = vector n
+
+ compareTwoRuntimes c
+ " Array" (fun () -> for i in 1..count do array.[r.Next n] |> ignore)
+ " PersistentVector" (fun () -> for i in 1..count do nth (r.Next n) vector |> ignore)
+
+
+let replaceInArrayAndVector n count =
+ printfn "%d writes in size n = %d" count n
+ let array = array n
+ let vector = vector n
+
+ compareTwoRuntimes c
+ " Array" (fun () -> for i in 1..count do array.[r.Next n] <- r.Next())
+ " PersistentVector" (fun () -> for i in 1..count do assocN (r.Next n) (r.Next()) vector |> ignore)
+
+initArrayAndVector 10000
+initArrayAndVector 100000
+initArrayAndVector 1000000
+
+lookupInArrayAndVector 10000 10000
+lookupInArrayAndVector 100000 10000
+lookupInArrayAndVector 1000000 10000
+lookupInArrayAndVector 10000000 10000
+
+replaceInArrayAndVector 10000 10000
+replaceInArrayAndVector 100000 10000
+replaceInArrayAndVector 1000000 10000
+replaceInArrayAndVector 10000000 10000
+
+printfn "Ready."
+System.Console.ReadKey() |> ignore
@@ -34,6 +34,17 @@
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Release\DiningPhilosophers.XML</DocumentationFile>
</PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DataStructures|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <Tailcalls>false</Tailcalls>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <PlatformTarget>x86</PlatformTarget>
+ <DocumentationFile>bin\Debug\DiningPhilosophers.XML</DocumentationFile>
+ <OutputPath>bin\DataStructures\</OutputPath>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core" />
View
@@ -33,6 +33,16 @@
<WarningLevel>3</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DataStructures|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <Tailcalls>false</Tailcalls>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <PlatformTarget>x86</PlatformTarget>
+ <OutputPath>bin\DataStructures\</OutputPath>
+ </PropertyGroup>
<Import Project="..\..\lib\FSharp\Microsoft.FSharp.Targets" />
<ItemGroup>
<Reference Include="FSharp.Core" Condition="'$(TargetFrameworkVersion)' != 'v3.5'">
@@ -55,4 +65,4 @@
<Private>True</Private>
</ProjectReference>
</ItemGroup>
-</Project>
+</Project>
@@ -59,6 +59,17 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DataStructures|AnyCPU'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\DataStructures\</OutputPath>
+ <DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <DebugType>full</DebugType>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <NoConfig>true</NoConfig>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="FSharp.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="mscorlib" />
@@ -112,4 +123,4 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
-</Project>
+</Project>
@@ -35,6 +35,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DataStructures|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\DataStructures\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@@ -35,6 +35,17 @@
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Release\UndoSample.XML</DocumentationFile>
</PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DataStructures|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <Tailcalls>false</Tailcalls>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <PlatformTarget>x86</PlatformTarget>
+ <DocumentationFile>bin\Debug\UndoSample.XML</DocumentationFile>
+ <OutputPath>bin\DataStructures\</OutputPath>
+ </PropertyGroup>
<Import Project="..\..\lib\FSharp\Microsoft.FSharp.Targets" />
<ItemGroup>
<Reference Include="FSharp.Core" Condition="'$(TargetFrameworkVersion)' != 'v3.5'">
@@ -64,4 +75,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
@@ -15,4 +15,19 @@ let stopAverageTime count f =
sw.Start()
let results = List.map (fun _ -> f()) list
sw.Stop()
- results,float sw.ElapsedMilliseconds / float count
+ results,float sw.ElapsedMilliseconds / float count
+
+/// Stops the average runtime for a given function and applies it the given count
+/// Afterwards it reports it with the given description
+let stopAndReportAvarageTime count desc f =
+ let results,time = stopAverageTime count f
+ printfn "%s %Ams" desc time
+ results,time
+
+/// Stops the average runtime for the given functions
+/// Afterwards it reports it with the given descriptions
+let compareTwoRuntimes count desc1 f1 desc2 f2 =
+ let _,time1 = stopAndReportAvarageTime count desc1 f1
+ let _,time2 = stopAndReportAvarageTime count desc2 f2
+
+ printfn " Ratio: %A" (time1 / time2)
@@ -32,6 +32,15 @@
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\FSharpx.Http.XML</DocumentationFile>
</PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DataStructures|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <Tailcalls>false</Tailcalls>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <OutputPath>bin\DataStructures\</OutputPath>
+ </PropertyGroup>
<Import Project="..\..\lib\FSharp\Microsoft.FSharp.Targets" />
<ItemGroup>
<Reference Include="FSharp.Core" Condition="'$(TargetFrameworkVersion)' == 'v4.0'">
@@ -39,6 +39,17 @@
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\FSharpx.Observable.Silverlight.XML</DocumentationFile>
</PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DataStructures|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>3</WarningLevel>
+ <DocumentationFile>bin\Debug\FSharpx.Observable.Silverlight.XML</DocumentationFile>
+ <OutputPath>bin\DataStructures\</OutputPath>
+ <NoConfig>true</NoConfig>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core">
@@ -52,10 +63,18 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="..\FSharpx.Core\Agents\Agent.fs" />
- <Compile Include="..\FSharpx.Core\Agents\BatchProcessingAgent.fs" />
- <Compile Include="..\FSharpx.Core\Agents\SlidingWindowAgent.fs" />
- <Compile Include="..\FSharpx.Core\Observable.fs" />
+ <Compile Include="..\FSharpx.Core\Agents\Agent.fs">
+ <Link>Agent.fs</Link>
+ </Compile>
+ <Compile Include="..\FSharpx.Core\Agents\BatchProcessingAgent.fs">
+ <Link>BatchProcessingAgent.fs</Link>
+ </Compile>
+ <Compile Include="..\FSharpx.Core\Agents\SlidingWindowAgent.fs">
+ <Link>SlidingWindowAgent.fs</Link>
+ </Compile>
+ <Compile Include="..\FSharpx.Core\Observable.fs">
+ <Link>Observable.fs</Link>
+ </Compile>
<Compile Include="ObservableDispatcherExtensions.fs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.5\Microsoft.FSharp.Targets" Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.5\Microsoft.FSharp.Targets')" />
@@ -70,4 +89,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
@@ -33,6 +33,16 @@
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\FSharpx.Observable.XML</DocumentationFile>
</PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DataStructures|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <Tailcalls>false</Tailcalls>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <DocumentationFile>bin\Debug\FSharpx.Observable.XML</DocumentationFile>
+ <OutputPath>bin\DataStructures\</OutputPath>
+ </PropertyGroup>
<Import Project="..\..\lib\FSharp\Microsoft.FSharp.Targets" />
<ItemGroup>
<Reference Include="mscorlib" />
@@ -31,6 +31,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DataStructures|AnyCPU'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\DataStructures\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="FSharp.Core" Condition="$(TargetFrameworkVersion) != 'v3.5'">
<HintPath>..\..\lib\FSharp\FSharp.Core.dll</HintPath>
Oops, something went wrong.

0 comments on commit d221101

Please sign in to comment.