/
iterators-benchmark3.html
194 lines (192 loc) 路 8.23 KB
/
iterators-benchmark3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Performance Comparison between for, foreach, and ForEeach() method</title>
<style type="text/css">
body { font-family: system-ui; padding: 0 30px 30px 30px; width: min-content; display: inline-block; }
h1, h2 { border-bottom: solid 1px #D8DEE4;}
h1, h2, h3 { padding-bottom: 0.3em; }
table { border-collapse: collapse !important; margin-top: 3px !important; width: 100%; display: inline-table; margin-bottom: 20px !important; }
td, th { padding: 6px 13px; border: 1px solid #CCC; text-align: right; white-space: nowrap; }
tr { background-color: #FFF !important; border-top: 1px solid #CCC; }
tr:nth-child(even):not(.divider) { background: #F8F8F8 !important; }
tr.divider { border: 0; font-size: 10px; }
tr.divider td { padding: 0; border: 0; }
pre { background: #EFEFEF; padding: 0 1em; }
thead th { background-color: #EFEFEF; }
tbody tr:not(.divider):hover { background-color: #EFEFEF !important; border: 2px solid #ADADAD; }
.powered-by { text-align: center; margin-bottom: -20px !important; font-weight: bold; }
</style>
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.7/css/jquery.dataTables.min.css" />
<link rel="stylesheet" href="https://cdn.datatables.net/colreorder/1.5.4/css/colReorder.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.4.2/css/buttons.dataTables.min.css">
<style type="text/css">
input[type="search"] { font-size: 1em !important; padding: 9px 12px !important; }
thead th:hover { background-color: #E0E0E0; }
</style>
</head>
<body>
<h1>Performance Comparison between for, foreach, and ForEeach() method</h1>
<pre>
<code>
BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3)
AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores
.NET SDK 8.0.101
[Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2
ShortRun-.NET 5.0 : .NET 5.0.17 (5.0.1722.21314), X64 RyuJIT AVX2
ShortRun-.NET 6.0 : .NET 6.0.26 (6.0.2623.60508), X64 RyuJIT AVX2
ShortRun-.NET 7.0 : .NET 7.0.15 (7.0.1523.57226), X64 RyuJIT AVX2
ShortRun-.NET 8.0 : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2
ShortRun-.NET Core 3.0 : .NET Core 3.1.32 (CoreCLR 4.700.22.55902, CoreFX 4.700.22.56512), X64 RyuJIT AVX2
ShortRun-.NET Core 3.1 : .NET Core 3.1.32 (CoreCLR 4.700.22.55902, CoreFX 4.700.22.56512), X64 RyuJIT AVX2
IterationCount=3 LaunchCount=1 WarmupCount=3
</code>
</pre>
<h2>Comparison: Mean</h2>
<table>
<thead>
<tr>
<th>Runtime</th><th>Categories</th><th>Length</th><th>for</th><th>foreach</th><th>ForEach()</th></tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">.NET 8.0</td>
<td style="text-align: left;background-color: #FFCCFF">Array</td>
<td style="background-color: #FFCCFF">1000</td>
<td style="background-color: #99FF99"><strong>239.1 ns</strong></td>
<td style="background-color: #99FF99"><strong>234.4 ns</strong></td>
<td style="background-color: #99FF99"><strong>467.2 ns</strong></td>
</tr>
<tr>
<td style="text-align: left">.NET 7.0</td>
<td style="text-align: left;background-color: #FFCCFF">Array</td>
<td style="background-color: #FFCCFF">1000</td>
<td style="background-color: #9AFF99">239.9 ns</td>
<td style="background-color: #9FFF99">238.4 ns</td>
<td style="background-color: #FFCD99">1,476.6 ns</td>
</tr>
<tr>
<td style="text-align: left">.NET 6.0</td>
<td style="text-align: left;background-color: #FFCCFF">Array</td>
<td style="background-color: #FFCCFF">1000</td>
<td style="background-color: #A1FF99">244.0 ns</td>
<td style="background-color: #9BFF99">235.9 ns</td>
<td style="background-color: #FFD799">1,410.8 ns</td>
</tr>
<tr>
<td style="text-align: left">.NET 5.0</td>
<td style="text-align: left;background-color: #FFCCFF">Array</td>
<td style="background-color: #FFCCFF">1000</td>
<td style="background-color: #C4FF99">267.8 ns</td>
<td style="background-color: #FF9999">487.2 ns</td>
<td style="background-color: #FFD599">1,424.1 ns</td>
</tr>
<tr>
<td style="text-align: left">.NET Core 3.0</td>
<td style="text-align: left;background-color: #FFCCFF">Array</td>
<td style="background-color: #FFCCFF">1000</td>
<td style="background-color: #DAFF99">286.5 ns</td>
<td style="background-color: #FFC399">465.4 ns</td>
<td style="background-color: #FF9999">1,627.6 ns</td>
</tr>
<tr>
<td style="text-align: left">.NET Core 3.1</td>
<td style="text-align: left;background-color: #FFCCFF">Array</td>
<td style="background-color: #FFCCFF">1000</td>
<td style="background-color: #DCFF99">288.7 ns</td>
<td style="background-color: #9BFF99">235.7 ns</td>
<td style="background-color: #FFD999">1,397.3 ns</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>Runtime</th><th>Categories</th><th>Length</th><th>for</th><th>foreach</th><th>ForEach()</th></tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">.NET 8.0</td>
<td style="text-align: left;background-color: #CCFFFF">List</td>
<td style="background-color: #CCFFFF">1000</td>
<td style="background-color: #99FF99"><strong>353.5 ns</strong></td>
<td style="background-color: #99FF99"><strong>407.7 ns</strong></td>
<td style="background-color: #99FF99"><strong>704.2 ns</strong></td>
</tr>
<tr>
<td style="text-align: left">.NET 6.0</td>
<td style="text-align: left;background-color: #CCFFFF">List</td>
<td style="background-color: #CCFFFF">1000</td>
<td style="background-color: #99FF99">353.6 ns</td>
<td style="background-color: #DBFF99">706.2 ns</td>
<td style="background-color: #FF9999">1,646.3 ns</td>
</tr>
<tr>
<td style="text-align: left">.NET 5.0</td>
<td style="text-align: left;background-color: #CCFFFF">List</td>
<td style="background-color: #CCFFFF">1000</td>
<td style="background-color: #99FF99">354.0 ns</td>
<td style="background-color: #FF9999">1,868.0 ns</td>
<td style="background-color: #FFAA99">1,632.8 ns</td>
</tr>
<tr>
<td style="text-align: left">.NET Core 3.0</td>
<td style="text-align: left;background-color: #CCFFFF">List</td>
<td style="background-color: #CCFFFF">1000</td>
<td style="background-color: #F4FF99">472.1 ns</td>
<td style="background-color: #FFCF99">1,658.8 ns</td>
<td style="background-color: #FFAB99">1,631.3 ns</td>
</tr>
<tr>
<td style="text-align: left">.NET Core 3.1</td>
<td style="text-align: left;background-color: #CCFFFF">List</td>
<td style="background-color: #CCFFFF">1000</td>
<td style="background-color: #F4FF99">473.1 ns</td>
<td style="background-color: #FFD099">1,653.8 ns</td>
<td style="background-color: #FFD899">1,467.3 ns</td>
</tr>
<tr>
<td style="text-align: left">.NET 7.0</td>
<td style="text-align: left;background-color: #CCFFFF">List</td>
<td style="background-color: #CCFFFF">1000</td>
<td style="background-color: #F5FF99">475.0 ns</td>
<td style="background-color: #A9FF99">470.3 ns</td>
<td style="background-color: #FFC599">1,560.1 ns</td>
</tr>
</tbody>
</table>
<div class="powered-by">Powered by <a href="https://github.com/mjebrahimi/BenchmarkDotNetVisualizer">https://github.com/mjebrahimi/BenchmarkDotNetVisualizer</a></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/colreorder/1.5.4/js/dataTables.colReorder.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.4.2/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.colVis.min.js"></script>
</body>
<script>
$(document).ready( function () {
DataTable.ext.type.order['custom-orderer-pre'] = function (d) {
d = d.replace(/(<([^>]+)>)/gi, ""); //remove html tags
if (!d.match(/^\d/)) //if not started with number
return d;
var regex = /[\d,]+(?:\.\d+)?/;
var number = d.match(regex)[0].replace(/,/g, ""); //extract number
return parseFloat(number); //Number
};
$('table').DataTable({
info: false,
paging: false,
colReorder: true,
order: [], //remove default order
columnDefs: [
{
type: 'custom-orderer',
targets: '_all'
}
],
dom: 'Bfrtip',
buttons: ['colvis']
});
});
</script>
</html>