-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBenchmark.cs
More file actions
697 lines (637 loc) · 27.9 KB
/
Benchmark.cs
File metadata and controls
697 lines (637 loc) · 27.9 KB
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Jobs;
using System.Text;
using BenchmarkDotNet.Columns;
namespace SimdUnicodeBenchmarks
{
#pragma warning disable CA1515
public class Speed : IColumn
{
static long GetDirectorySize(string folderPath)
{
long totalSize = 0;
DirectoryInfo di = new DirectoryInfo(folderPath);
foreach (FileInfo fi in di.EnumerateFiles("*.*", SearchOption.AllDirectories))
{
totalSize += fi.Length;
}
return totalSize;
}
public string GetValue(Summary summary, BenchmarkCase benchmarkCase)
{
#pragma warning disable CA1062
var ourReport = summary.Reports.First(x => x.BenchmarkCase.Equals(benchmarkCase));
var fileName = (string)benchmarkCase.Parameters["FileName"];
long length = 0;
if (File.Exists(fileName))
{
length = new System.IO.FileInfo(fileName).Length;
}
else if (Directory.Exists(fileName))
{
length = GetDirectorySize(fileName);
}
if (ourReport.ResultStatistics is null)
{
return "N/A";
}
var mean = ourReport.ResultStatistics.Mean;
return $"{(length / ourReport.ResultStatistics.Mean):#####.00}";
}
public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) => GetValue(summary, benchmarkCase);
public bool IsDefault(Summary summary, BenchmarkCase benchmarkCase) => false;
public bool IsAvailable(Summary summary) => true;
public string Id { get; } = nameof(Speed);
public string ColumnName { get; } = "Speed (GB/s)";
public bool AlwaysShow { get; } = true;
public ColumnCategory Category { get; } = ColumnCategory.Custom;
#pragma warning disable CA1805
public int PriorityInCategory { get; } = 0;
#pragma warning disable CA1805
public bool IsNumeric { get; } = false;
public UnitType UnitType { get; } = UnitType.Dimensionless;
public string Legend { get; } = "The speed in gigabytes per second";
}
#pragma warning disable CA1515
public class DataVolume : IColumn
{
static double GetDirectorySize(string folderPath)
{
double totalSize = 0;
DirectoryInfo di = new DirectoryInfo(folderPath);
long fileCount = di.EnumerateFiles("*.*", SearchOption.AllDirectories).Count();
foreach (FileInfo fi in di.EnumerateFiles("*.*", SearchOption.AllDirectories))
{
totalSize += fi.Length;
}
return totalSize / fileCount;
}
public string GetValue(Summary summary, BenchmarkCase benchmarkCase)
{
#pragma warning disable CA1062
var ourReport = summary.Reports.First(x => x.BenchmarkCase.Equals(benchmarkCase));
var fileName = (string)benchmarkCase.Parameters["FileName"];
double length = 0;
if (File.Exists(fileName))
{
FileInfo fi = new FileInfo(fileName);
length = fi.Length;
length /= File.ReadAllLines(fi.FullName).Length;
}
else if (Directory.Exists(fileName))
{
length = GetDirectorySize(fileName);
}
if (ourReport.ResultStatistics is null)
{
return "N/A";
}
return $"{length / 1000:#####.00}";
}
public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) => GetValue(summary, benchmarkCase);
public bool IsDefault(Summary summary, BenchmarkCase benchmarkCase) => false;
public bool IsAvailable(Summary summary) => true;
public string Id { get; } = nameof(DataVolume);
public string ColumnName { get; } = "kiB/input";
public bool AlwaysShow { get; } = true;
public ColumnCategory Category { get; } = ColumnCategory.Custom;
#pragma warning disable CA1805
public int PriorityInCategory { get; } = 0;
#pragma warning disable CA1805
public bool IsNumeric { get; } = false;
public UnitType UnitType { get; } = UnitType.Dimensionless;
public string Legend { get; } = "The average data volume in kilobytes per input";
}
[SimpleJob(launchCount: 1, warmupCount: 10, iterationCount: 20)]
[Config(typeof(Config))]
#pragma warning disable CA1515
public class RealDataBenchmark
{
#pragma warning disable CA1812
private sealed class Config : ManualConfig
{
public Config()
{
AddColumn(new DataVolume());
AddColumn(new Speed());
}
}
// Parameters and variables for real data
[Params(
@"data/email/",
@"data/dns/swedenzonebase.txt"
)]
#pragma warning disable CA1051
public string? FileName;
#pragma warning disable CS8618
public string[] FileContent;
public int[] DecodedLengths;
public byte[][] output; // precomputed byte outputs (with correct size)
public byte[][] input; // precomputed byte inputs
public char[][] input16; // precomputed char inputs
public void RunRuntimeDecodingBenchmarkUTF16(string[] data, int[] lengths)
{
foreach (string s in FileContent)
{
Convert.FromBase64String(s);
}
}
// Note: The runtime decoding uses advanced SIMD instructions, including AVX-512.
// Thus on systems with > SSSE3 support, it might beat our SSE implementation.
// See https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64DecoderHelper.cs
public void RunRuntimeSIMDDecodingBenchmarkUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
System.Buffers.Text.Base64.DecodeFromUtf8(input[i].AsSpan(), output[i].AsSpan(), out int consumed, out int written);
if (written != lengths[i])
{
Console.WriteLine($"Error: {written} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
// Note: The runtime decoding uses advanced SIMD instructions, including AVX-512.
// See https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64DecoderHelper.cs
// Thus on systems with > SSSE3 support, it might beat our SSE implementation.
public void RunRuntimeSIMDDecodingBenchmarkWithAllocUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
byte[] outputdata = new byte[System.Buffers.Text.Base64.GetMaxDecodedFromUtf8Length(input[i].Length)];
System.Buffers.Text.Base64.DecodeFromUtf8(input[i].AsSpan(), outputdata.AsSpan(), out int consumed, out int written);
if (written != lengths[i])
{
Console.WriteLine($"Error: {written} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunGfoidlDecodingBenchmarkUTF16(string[] data, int[] lengths)
{
// gfoidl does not appear to always succeed. Note that
// the decoding was not integrated into the DOTNET runtime.
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
ReadOnlySpan<char> span = s.ToCharArray();
Span<byte> dataout = output[i];
int consumed = 0;
int written = 0;
gfoidl.Base64.Base64.Default.Decode(span, dataout, out consumed, out written, true);
if (written != lengths[i])
{
Console.WriteLine($"Error: {written} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunScalarDecodingBenchmarkUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
byte[] base64 = input[i];
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.Scalar.Base64.Base64WithWhiteSpaceToBinaryScalar(base64.AsSpan(), dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunScalarDecodingBenchmarkUTF16(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
char[] base64 = input16[i];
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.Scalar.Base64.Base64WithWhiteSpaceToBinaryScalar(base64.AsSpan(), dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunSSEDecodingBenchmarkUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
byte[] base64 = input[i];
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.SSE.Base64.DecodeFromBase64SSE(base64.AsSpan(), dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunSSEDecodingBenchmarkUTF16(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
ReadOnlySpan<char> base64 = s.AsSpan();
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.SSE.Base64.DecodeFromBase64SSE(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunSSEDecodingBenchmarkWithAllocUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
Span<byte> base64 = input[i].AsSpan();
byte[] dataoutput = new byte[SimdBase64.Base64.MaximalBinaryLengthFromBase64<byte>(base64)];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.SSE.Base64.DecodeFromBase64SSE(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunSSEDecodingBenchmarkWithAllocUTF16(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
Span<char> base64 = input16[i].AsSpan();
byte[] dataoutput = new byte[SimdBase64.Base64.MaximalBinaryLengthFromBase64<char>(base64)];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.SSE.Base64.DecodeFromBase64SSE(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunAVX2DecodingBenchmarkUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
byte[] base64 = input[i];
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.AVX2.Base64.DecodeFromBase64AVX2(base64.AsSpan(), dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunOurDecodingBenchmarkUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
byte[] base64 = input[i];
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.Base64.DecodeFromBase64(base64.AsSpan(), dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunAVX2DecodingBenchmarkUTF16(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
ReadOnlySpan<char> base64 = s.AsSpan();
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.AVX2.Base64.DecodeFromBase64AVX2(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunOurDecodingBenchmarkUTF16(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
ReadOnlySpan<char> base64 = s.AsSpan();
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.Base64.DecodeFromBase64(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunAVX2DecodingBenchmarkWithAllocUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
Span<byte> base64 = input[i].AsSpan();
byte[] dataoutput = new byte[SimdBase64.Base64.MaximalBinaryLengthFromBase64<byte>(base64)];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.AVX2.Base64.DecodeFromBase64AVX2(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunAVX2DecodingBenchmarkWithAllocUTF16(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
Span<char> base64 = input16[i].AsSpan();
byte[] dataoutput = new byte[SimdBase64.Base64.MaximalBinaryLengthFromBase64<char>(base64)];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.AVX2.Base64.DecodeFromBase64AVX2(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunOurDecodingBenchmarkWithAllocUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
Span<byte> base64 = input[i].AsSpan();
byte[] dataoutput = new byte[SimdBase64.Base64.MaximalBinaryLengthFromBase64<byte>(base64)];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.Base64.DecodeFromBase64(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunOurDecodingBenchmarkWithAllocUTF16(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
byte[] dataoutput = SimdBase64.Base64.FromBase64String(s);
if (dataoutput.Length != lengths[i])
{
Console.WriteLine($"Error: {dataoutput.Length} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunARMDecodingBenchmarkUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
byte[] base64 = input[i];
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.Arm.Base64.DecodeFromBase64ARM(base64.AsSpan(), dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunARMDecodingBenchmarkUTF16(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
ReadOnlySpan<char> base64 = s.AsSpan();
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.Arm.Base64.DecodeFromBase64ARM(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunARMDecodingBenchmarkWithAllocUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
Span<byte> base64 = input[i].AsSpan();
byte[] dataoutput = new byte[SimdBase64.Base64.MaximalBinaryLengthFromBase64<byte>(base64)];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.Arm.Base64.DecodeFromBase64ARM(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
public unsafe void RunARMDecodingBenchmarkWithAllocUTF16(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
Span<char> base64 = input16[i].AsSpan();
byte[] dataoutput = new byte[SimdBase64.Base64.MaximalBinaryLengthFromBase64<char>(base64)];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.Arm.Base64.DecodeFromBase64ARM(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}
[GlobalSetup]
public void Setup()
{
Console.WriteLine($"FileContent : {FileName}");
if (FileName == "data/dns/swedenzonebase.txt")
{
FileContent = File.ReadAllLines(FileName);
DecodedLengths = new int[FileContent.Length];
output = new byte[FileContent.Length][];
input = new byte[FileContent.Length][];
input16 = new char[FileContent.Length][];
for (int i = 0; i < FileContent.Length; i++)
{
DecodedLengths[i] = Convert.FromBase64String(FileContent[i]).Length;
output[i] = new byte[DecodedLengths[i]];
input[i] = Encoding.UTF8.GetBytes(FileContent[i]);
input16[i] = FileContent[i].ToCharArray();
}
}
else if (FileName == "data/email/")
{
string[] fileNames = Directory.GetFiles(FileName);
FileContent = new string[fileNames.Length];
DecodedLengths = new int[fileNames.Length];
output = new byte[FileContent.Length][];
input = new byte[FileContent.Length][];
input16 = new char[FileContent.Length][];
for (int i = 0; i < fileNames.Length; i++)
{
FileContent[i] = File.ReadAllText(fileNames[i]);
DecodedLengths[i] = Convert.FromBase64String(FileContent[i]).Length;
output[i] = new byte[DecodedLengths[i]];
input[i] = Encoding.UTF8.GetBytes(FileContent[i]);
input16[i] = FileContent[i].ToCharArray();
}
}
else
{
FileContent = [];
}
}
[Benchmark]
[BenchmarkCategory("default", "runtime")]
public unsafe void DotnetRuntimeSIMDBase64RealDataUTF8()
{
RunRuntimeSIMDDecodingBenchmarkUTF8(FileContent, DecodedLengths);
}
public unsafe void DotnetRuntimeSIMDBase64RealDataWithAllocUTF8()
{
RunRuntimeSIMDDecodingBenchmarkWithAllocUTF8(FileContent, DecodedLengths);
}
[Benchmark]
[BenchmarkCategory("UTF16")]
public unsafe void DotnetRuntimeBase64RealDataUTF16()
{
RunRuntimeDecodingBenchmarkUTF16(FileContent, DecodedLengths);
}
public unsafe void SSEDecodingRealDataUTF8()
{
RunSSEDecodingBenchmarkUTF8(FileContent, DecodedLengths);
}
public unsafe void SSEDecodingRealDataWithAllocUTF8()
{
RunSSEDecodingBenchmarkWithAllocUTF8(FileContent, DecodedLengths);
}
public unsafe void AVX2DecodingRealDataUTF8()
{
RunAVX2DecodingBenchmarkUTF8(FileContent, DecodedLengths);
}
[Benchmark]
[BenchmarkCategory("default")]
public unsafe void SimdBase64DecodingRealDataUTF8()
{
RunOurDecodingBenchmarkUTF8(FileContent, DecodedLengths);
}
[Benchmark]
[BenchmarkCategory("UTF16")]
public unsafe void SimdBase64DecodingRealDataWithAllocUTF16()
{
RunOurDecodingBenchmarkWithAllocUTF16(FileContent, DecodedLengths);
}
public unsafe void AVX2DecodingRealDataWithAllocUTF8()
{
RunAVX2DecodingBenchmarkWithAllocUTF8(FileContent, DecodedLengths);
}
public unsafe void ARMDecodingRealDataUTF8()
{
RunARMDecodingBenchmarkUTF8(FileContent, DecodedLengths);
}
public unsafe void ARMDecodingRealDataWithAllocUTF8()
{
RunARMDecodingBenchmarkWithAllocUTF8(FileContent, DecodedLengths);
}
public unsafe void ARMDecodingRealDataUTF16()
{
RunARMDecodingBenchmarkUTF16(FileContent, DecodedLengths);
}
public unsafe void SSEDecodingRealDataUTF16()
{
RunSSEDecodingBenchmarkUTF16(FileContent, DecodedLengths);
}
public unsafe void SSEDecodingRealDataWithAllocUTF16()
{
RunSSEDecodingBenchmarkWithAllocUTF16(FileContent, DecodedLengths);
}
public unsafe void AVX2DecodingRealDataUTF16()
{
RunAVX2DecodingBenchmarkUTF16(FileContent, DecodedLengths);
}
public unsafe void AVX2DecodingRealDataWithAllocUTF16()
{
RunAVX2DecodingBenchmarkWithAllocUTF16(FileContent, DecodedLengths);
}
}
#pragma warning disable CA1515
public class Program
{
static void Main(string[] args)
{
if (args.Length == 0)
{
args = new string[] { "--filter", "*", "--anyCategories", "default" };
}
var job = Job.Default
.WithWarmupCount(1)
.WithMinIterationCount(2)
.WithMaxIterationCount(10)
.AsDefault();
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, DefaultConfig.Instance.AddJob(job).WithSummaryStyle(SummaryStyle.Default.WithMaxParameterColumnWidth(100)));
}
}
}