Skip to content

Commit d4487a6

Browse files
committed
uploading all benchmarks.
1 parent f60e71c commit d4487a6

16 files changed

+2206
-12
lines changed

.gitignore

+226
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
# The following command works for downloading when using Git for Windows:
2+
# curl -LOf http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
3+
#
4+
# Download this file using PowerShell v3 under Windows with the following comand:
5+
# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore
6+
#
7+
# or wget:
8+
# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
9+
10+
# User-specific files
11+
*.suo
12+
*.user
13+
*.sln.docstates
14+
15+
# Build results
16+
[Dd]ebug/
17+
[Rr]elease/
18+
x64/
19+
[Bb]in/
20+
[Oo]bj/
21+
# build folder is nowadays used for build scripts and should not be ignored
22+
#build/
23+
24+
# NuGet Packages
25+
*.nupkg
26+
# The packages folder can be ignored because of Package Restore
27+
**/packages/*
28+
# except build/, which is used as an MSBuild target.
29+
!**/packages/build/
30+
# Uncomment if necessary however generally it will be regenerated when needed
31+
#!**/packages/repositories.config
32+
33+
# MSTest test Results
34+
[Tt]est[Rr]esult*/
35+
[Bb]uild[Ll]og.*
36+
37+
*_i.c
38+
*_p.c
39+
*.ilk
40+
*.meta
41+
*.obj
42+
*.pch
43+
*.pdb
44+
*.pgc
45+
*.pgd
46+
*.rsp
47+
*.sbr
48+
*.tlb
49+
*.tli
50+
*.tlh
51+
*.tmp
52+
*.tmp_proj
53+
*.log
54+
*.vspscc
55+
*.vssscc
56+
.builds
57+
*.pidb
58+
*.scc
59+
60+
# Visual C++ cache files
61+
ipch/
62+
*.aps
63+
*.ncb
64+
*.opensdf
65+
*.sdf
66+
*.cachefile
67+
68+
# Visual Studio profiler
69+
*.psess
70+
*.vsp
71+
*.vspx
72+
73+
# Guidance Automation Toolkit
74+
*.gpState
75+
76+
# ReSharper is a .NET coding add-in
77+
_ReSharper*/
78+
*.[Rr]e[Ss]harper
79+
80+
# TeamCity is a build add-in
81+
_TeamCity*
82+
83+
# DotCover is a Code Coverage Tool
84+
*.dotCover
85+
86+
# NCrunch
87+
*.ncrunch*
88+
.*crunch*.local.xml
89+
90+
# Installshield output folder
91+
[Ee]xpress/
92+
93+
# DocProject is a documentation generator add-in
94+
DocProject/buildhelp/
95+
DocProject/Help/*.HxT
96+
DocProject/Help/*.HxC
97+
DocProject/Help/*.hhc
98+
DocProject/Help/*.hhk
99+
DocProject/Help/*.hhp
100+
DocProject/Help/Html2
101+
DocProject/Help/html
102+
103+
# Click-Once directory
104+
publish/
105+
106+
# Publish Web Output
107+
*.Publish.xml
108+
109+
# Windows Azure Build Output
110+
csx
111+
*.build.csdef
112+
113+
# Windows Store app package directory
114+
AppPackages/
115+
116+
# Others
117+
*.Cache
118+
ClientBin/
119+
[Ss]tyle[Cc]op.*
120+
~$*
121+
*~
122+
*.dbmdl
123+
*.[Pp]ublish.xml
124+
*.pfx
125+
*.publishsettings
126+
modulesbin/
127+
tempbin/
128+
129+
# EPiServer Site file (VPP)
130+
AppData/
131+
132+
# RIA/Silverlight projects
133+
Generated_Code/
134+
135+
# Backup & report files from converting an old project file to a newer
136+
# Visual Studio version. Backup files are not needed, because we have git ;-)
137+
_UpgradeReport_Files/
138+
Backup*/
139+
UpgradeLog*.XML
140+
UpgradeLog*.htm
141+
142+
# vim
143+
*.txt~
144+
*.swp
145+
*.swo
146+
147+
# Temp files when opening LibreOffice on ubuntu
148+
.~lock.*
149+
150+
# svn
151+
.svn
152+
153+
# CVS - Source Control
154+
**/CVS/
155+
156+
# Remainings from resolving conflicts in Source Control
157+
*.orig
158+
159+
# SQL Server files
160+
**/App_Data/*.mdf
161+
**/App_Data/*.ldf
162+
**/App_Data/*.sdf
163+
164+
165+
#LightSwitch generated files
166+
GeneratedArtifacts/
167+
_Pvt_Extensions/
168+
ModelManifest.xml
169+
170+
# =========================
171+
# Windows detritus
172+
# =========================
173+
174+
# Windows image file caches
175+
Thumbs.db
176+
ehthumbs.db
177+
178+
# Folder config file
179+
Desktop.ini
180+
181+
# Recycle Bin used on file shares
182+
$RECYCLE.BIN/
183+
184+
# OS generated files #
185+
Icon?
186+
187+
# Mac desktop service store files
188+
.DS_Store
189+
190+
# SASS Compiler cache
191+
.sass-cache
192+
193+
# Visual Studio 2014 CTP
194+
**/*.sln.ide
195+
196+
# Visual Studio temp something
197+
.vs/
198+
199+
# dotnet stuff
200+
project.lock.json
201+
202+
# VS 2015+
203+
*.vc.vc.opendb
204+
*.vc.db
205+
206+
# Rider
207+
.idea/
208+
209+
# Visual Studio Code
210+
.vscode/
211+
212+
# Output folder used by Webpack or other FE stuff
213+
**/node_modules/*
214+
**/wwwroot/*
215+
216+
# SpecFlow specific
217+
*.feature.cs
218+
*.feature.xlsx.*
219+
*.Specs_*.html
220+
221+
# UWP Projects
222+
AppPackages/
223+
224+
#####
225+
# End of core ignore list, below put you custom 'per project' settings (patterns or path)
226+
#####

BenchmarkSharp/BenchmarkSharp.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@
1515
<PlatformTarget>x64</PlatformTarget>
1616
</PropertyGroup>
1717

18+
<ItemGroup>
19+
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
20+
</ItemGroup>
21+
1822
</Project>

BenchmarkSharp/Program.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
// See https://aka.ms/new-console-template for more information
1+
using BenchmarkDotNet.Running;
2+
using BenchmarkSharp.TestBenches;
23

3-
Console.WriteLine("Hello, World!");
4+
BenchmarkRunner.Run<ArrayPoolBench>();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using BenchmarkDotNet.Attributes;
2+
3+
namespace BenchmarkSharp.TestBenches;
4+
5+
[MemoryDiagnoser]
6+
public class ArrayDataModifyBench
7+
{
8+
[Benchmark]
9+
public void Normal_Array_Modify()
10+
{
11+
int[] data = new int[100]; // Allocate memory on the heap
12+
data[0] = 10;
13+
data[1] = 20;
14+
15+
for (int i = 0; i < 100; i++)
16+
{
17+
data[i] = data[i] * 2;
18+
}
19+
}
20+
21+
[Benchmark ]
22+
public void Span_Array_Modify()
23+
{
24+
Span<int> data = stackalloc int[100]; // Allocate memory on the stack
25+
data[0] = 10;
26+
data[1] = 20;
27+
28+
for (int i = 0; i < 100; i++)
29+
{
30+
data[i] = data[i] * 2;
31+
}
32+
}
33+
34+
[Benchmark ]
35+
public void Memory_Array_Modify()
36+
{
37+
Memory<int> data = new int[100];
38+
var spanData = data.Span;
39+
spanData[0] = 10;
40+
spanData[1] = 20;
41+
42+
for (int i = 0; i < 100; i++)
43+
{
44+
spanData[i] = spanData[i] * 2;
45+
}
46+
}
47+
48+
}

0 commit comments

Comments
 (0)