Skip to content

Commit b131605

Browse files
committed
Added more examples and .net6
1 parent 25333b4 commit b131605

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

BenchmarkDotNet8/BenchmarkDotNet8.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Nullable>enable</Nullable>
77
<LangVersion>preview</LangVersion>
88
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
9-
<TargetFrameworks>net8.0;net7.0</TargetFrameworks>
9+
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
1010
</PropertyGroup>
1111

1212
<ItemGroup>

BenchmarkDotNet8/Program.cs

+26
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
1111
[SimpleJob(RuntimeMoniker.Net80)]
12+
[SimpleJob(RuntimeMoniker.Net60)]
1213
[HideColumns(Column.Job, Column.RatioSD)]
1314
public class Benchmarks
1415
{
@@ -62,4 +63,29 @@ public string InvokeMethodViaReflection()
6263

6364
[Benchmark]
6465
public string[] EnumGetNames() => Enum.GetNames<DayOfWeek>();
66+
67+
[Benchmark]
68+
public List<int> ListAdd1000()
69+
{
70+
var list = new List<int>();
71+
for (var i = 0; i < 1000; i++)
72+
{
73+
list.Add(i);
74+
}
75+
76+
return list;
77+
}
78+
79+
[Benchmark]
80+
public int ListLookup()
81+
{
82+
var entriesFound = 0;
83+
for (var i = 0; i < 100; i++)
84+
{
85+
if (_numbers.Contains(i))
86+
entriesFound++;
87+
}
88+
89+
return entriesFound;
90+
}
6591
}

0 commit comments

Comments
 (0)