Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Update and addition to Performance tests #3764

Merged
merged 1 commit into from
Oct 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Documentation/project-docs/performance-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ For the time being, perf tests should reside within their own "Performance" fold

Start by adding the following lines to the tests csproj:
```
<!-- Performance tests require v5.0 portable tools -->
<PropertyGroup Condition="'$(RunPerfTestsForProject)' == 'true'">
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<!-- Performance Tests -->
<ItemGroup Condition="'$(RunPerfTestsForProject)' == 'true'">
<Compile Include="Performance\Perf.Dictionary.cs" />
Expand All @@ -63,7 +57,7 @@ Start by adding the following lines to the tests csproj:
Next, the project.json for the tests directory also needs to import the perf stuff:

```
"Microsoft.DotNet.xunit.performance": "1.0.0-alpha-build0022",
"Microsoft.DotNet.xunit.performance": "1.0.0-*",
"xunit": "2.1.0",
"xunit.netcore.extensions": "1.0.0-prerelease-*"
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ public class Perf_HashTable
public static Hashtable CreateHashtable(int size)
{
Hashtable ht = new Hashtable();
PerfUtils utils = new PerfUtils();
for (int i = 0; i < size; i++)
ht.Add(utils.CreateString(50), utils.CreateString(50));
Random rand = new Random(341553);
while (ht.Count < size)
{
int key = rand.Next(400000, int.MaxValue);
if (!ht.ContainsKey(key))
ht.Add(key, rand.Next());
}
return ht;
}

Expand All @@ -35,17 +39,21 @@ public void ctor()
}

[Benchmark]
[InlineData(1000)]
[InlineData(10000)]
[InlineData(100000)]
[InlineData(1000000)]
public void GetItem(int size)
{
Hashtable table = CreateHashtable(size);

// Setup - utils needs a specific seed to prevent key collision with TestData
object result;
PerfUtils utils = new PerfUtils(983452);
string key = utils.CreateString(50);
table.Add(key, "value");
Random rand = new Random(3453);
int key = rand.Next();
while (table.Contains(key))
key = rand.Next();
table.Add(key, rand.Next());
foreach (var iteration in Benchmark.Iterations)
{
using (iteration.StartMeasurement())
Expand All @@ -62,7 +70,35 @@ public void GetItem(int size)
}

[Benchmark]
[InlineData(1000)]
[InlineData(10000)]
[InlineData(100000)]
[InlineData(1000000)]
public void SetItem(int size)
{
Hashtable table = CreateHashtable(size);
Random rand = new Random(3453);
int key = rand.Next();
while (table.Contains(key))
key = rand.Next();
foreach (var iteration in Benchmark.Iterations)
{
using (iteration.StartMeasurement())
{
for (int i = 0; i < 40000; i++)
{
table[key] = "newValue"; table[key] = "newValue"; table[key] = "newValue";
table[key] = "newValue"; table[key] = "newValue"; table[key] = "newValue";
table[key] = "newValue"; table[key] = "newValue"; table[key] = "newValue";
}
}
}
}

[Benchmark]
[InlineData(1000)]
[InlineData(10000)]
[InlineData(100000)]
[InlineData(1000000)]
public void Add(int size)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
<AssemblyName>System.Collections.NonGeneric.Tests</AssemblyName>
<ProjectGuid>{EE95AE39-845A-42D3-86D0-8065DBE56612}</ProjectGuid>
</PropertyGroup>
<!-- Performance tests require v5.0 portable tools -->
<PropertyGroup Condition="'$(RunPerfTestsForProject)' == 'true'">
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>

<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
Expand Down
40 changes: 25 additions & 15 deletions src/System.Collections.NonGeneric/tests/project.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": 1,
"targets": {
"DNXCore,Version=v5.0": {
"Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": {
"Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": {
"type": "package",
"dependencies": {
"System.Collections": "4.0.10",
Expand Down Expand Up @@ -45,7 +45,7 @@
"lib/DNXCore50/System.Collections.dll": {}
}
},
"System.Console/4.0.0-beta-23401": {
"System.Console/4.0.0-beta-23409": {
"type": "package",
"dependencies": {
"System.IO": "4.0.0",
Expand Down Expand Up @@ -469,7 +469,7 @@
"lib/dotnet/xunit.execution.dotnet.dll": {}
}
},
"xunit.netcore.extensions/1.0.0-prerelease-00102": {
"xunit.netcore.extensions/1.0.0-prerelease-00105": {
"type": "package",
"dependencies": {
"System.Diagnostics.Debug": "4.0.10",
Expand Down Expand Up @@ -497,9 +497,9 @@
}
},
"libraries": {
"Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": {
"Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": {
"type": "package",
"sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==",
"sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==",
"files": [
"lib/dotnet/xunit.performance.core.dll",
"lib/dotnet/xunit.performance.core.pdb",
Expand All @@ -511,8 +511,8 @@
"lib/net46/xunit.performance.core.XML",
"lib/net46/xunit.performance.execution.desktop.dll",
"lib/net46/xunit.performance.execution.desktop.pdb",
"Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg",
"Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512",
"Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg",
"Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512",
"Microsoft.DotNet.xunit.performance.nuspec"
]
},
Expand Down Expand Up @@ -550,25 +550,35 @@
"System.Collections.nuspec"
]
},
"System.Console/4.0.0-beta-23401": {
"System.Console/4.0.0-beta-23409": {
"type": "package",
"serviceable": true,
"sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==",
"sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==",
"files": [
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net46/System.Console.dll",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"ref/dotnet/de/System.Console.xml",
"ref/dotnet/es/System.Console.xml",
"ref/dotnet/fr/System.Console.xml",
"ref/dotnet/it/System.Console.xml",
"ref/dotnet/ja/System.Console.xml",
"ref/dotnet/ko/System.Console.xml",
"ref/dotnet/ru/System.Console.xml",
"ref/dotnet/System.Console.dll",
"ref/dotnet/System.Console.xml",
"ref/dotnet/zh-hans/System.Console.xml",
"ref/dotnet/zh-hant/System.Console.xml",
"ref/MonoAndroid10/_._",
"ref/MonoTouch10/_._",
"ref/net46/System.Console.dll",
"ref/xamarinios10/_._",
"ref/xamarinmac20/_._",
"runtime.json",
"System.Console.4.0.0-beta-23401.nupkg",
"System.Console.4.0.0-beta-23401.nupkg.sha512",
"System.Console.4.0.0-beta-23409.nupkg",
"System.Console.4.0.0-beta-23409.nupkg.sha512",
"System.Console.nuspec"
]
},
Expand Down Expand Up @@ -1531,14 +1541,14 @@
"xunit.extensibility.execution.nuspec"
]
},
"xunit.netcore.extensions/1.0.0-prerelease-00102": {
"xunit.netcore.extensions/1.0.0-prerelease-00105": {
"type": "package",
"serviceable": true,
"sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==",
"sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==",
"files": [
"lib/dotnet/Xunit.NetCore.Extensions.dll",
"xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg",
"xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512",
"xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg",
"xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512",
"xunit.netcore.extensions.nuspec"
]
}
Expand Down
16 changes: 16 additions & 0 deletions src/System.Collections/tests/Performance/Perf.List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ public void Enumerator(int size)
foreach (var element in list) { }
}

[Benchmark]
[InlineData(1000)]
[InlineData(10000)]
[InlineData(100000)]
public void SetCapacity(int size)
{
List<object> list = CreateList(size);
foreach (var iteration in Benchmark.Iterations)
using (iteration.StartMeasurement())
for (int i = 0; i < 100; i++)
{
// Capacity set back and forth between size+1 and size+2
list.Capacity = size + (i % 2) + 1;
}
}

[Benchmark]
[InlineData(1000)]
[InlineData(10000)]
Expand Down
5 changes: 0 additions & 5 deletions src/System.Collections/tests/System.Collections.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
<AssemblyName>System.Collections.Tests</AssemblyName>
<RootNamespace>System.Collections.Tests</RootNamespace>
</PropertyGroup>
<!-- Performance tests require v5.0 portable tools -->
<PropertyGroup Condition="'$(RunPerfTestsForProject)' == 'true'">
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
Expand Down
40 changes: 25 additions & 15 deletions src/System.Collections/tests/project.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": 1,
"targets": {
"DNXCore,Version=v5.0": {
"Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": {
"Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": {
"type": "package",
"dependencies": {
"System.Collections": "4.0.10",
Expand Down Expand Up @@ -45,7 +45,7 @@
"lib/DNXCore50/System.Collections.dll": {}
}
},
"System.Console/4.0.0-beta-23401": {
"System.Console/4.0.0-beta-23409": {
"type": "package",
"dependencies": {
"System.IO": "4.0.0",
Expand Down Expand Up @@ -469,7 +469,7 @@
"lib/dotnet/xunit.execution.dotnet.dll": {}
}
},
"xunit.netcore.extensions/1.0.0-prerelease-00102": {
"xunit.netcore.extensions/1.0.0-prerelease-00105": {
"type": "package",
"dependencies": {
"System.Diagnostics.Debug": "4.0.10",
Expand Down Expand Up @@ -497,9 +497,9 @@
}
},
"libraries": {
"Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": {
"Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": {
"type": "package",
"sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==",
"sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==",
"files": [
"lib/dotnet/xunit.performance.core.dll",
"lib/dotnet/xunit.performance.core.pdb",
Expand All @@ -511,8 +511,8 @@
"lib/net46/xunit.performance.core.XML",
"lib/net46/xunit.performance.execution.desktop.dll",
"lib/net46/xunit.performance.execution.desktop.pdb",
"Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg",
"Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512",
"Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg",
"Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512",
"Microsoft.DotNet.xunit.performance.nuspec"
]
},
Expand Down Expand Up @@ -550,25 +550,35 @@
"System.Collections.nuspec"
]
},
"System.Console/4.0.0-beta-23401": {
"System.Console/4.0.0-beta-23409": {
"type": "package",
"serviceable": true,
"sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==",
"sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==",
"files": [
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net46/System.Console.dll",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"ref/dotnet/de/System.Console.xml",
"ref/dotnet/es/System.Console.xml",
"ref/dotnet/fr/System.Console.xml",
"ref/dotnet/it/System.Console.xml",
"ref/dotnet/ja/System.Console.xml",
"ref/dotnet/ko/System.Console.xml",
"ref/dotnet/ru/System.Console.xml",
"ref/dotnet/System.Console.dll",
"ref/dotnet/System.Console.xml",
"ref/dotnet/zh-hans/System.Console.xml",
"ref/dotnet/zh-hant/System.Console.xml",
"ref/MonoAndroid10/_._",
"ref/MonoTouch10/_._",
"ref/net46/System.Console.dll",
"ref/xamarinios10/_._",
"ref/xamarinmac20/_._",
"runtime.json",
"System.Console.4.0.0-beta-23401.nupkg",
"System.Console.4.0.0-beta-23401.nupkg.sha512",
"System.Console.4.0.0-beta-23409.nupkg",
"System.Console.4.0.0-beta-23409.nupkg.sha512",
"System.Console.nuspec"
]
},
Expand Down Expand Up @@ -1531,14 +1541,14 @@
"xunit.extensibility.execution.nuspec"
]
},
"xunit.netcore.extensions/1.0.0-prerelease-00102": {
"xunit.netcore.extensions/1.0.0-prerelease-00105": {
"type": "package",
"serviceable": true,
"sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==",
"sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==",
"files": [
"lib/dotnet/Xunit.NetCore.Extensions.dll",
"xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg",
"xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512",
"xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg",
"xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512",
"xunit.netcore.extensions.nuspec"
]
}
Expand Down
Loading