Skip to content

Commit

Permalink
Merge branch 'main' into Arm
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lemire committed Aug 24, 2024
2 parents 83e8d6d + e59e906 commit 0bdd958
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions benchmark/Benchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public string GetValue(Summary summary, BenchmarkCase benchmarkCase)
}


[SimpleJob(launchCount: 1, warmupCount: 3, iterationCount: 3)]
[SimpleJob(launchCount: 1, warmupCount: 5, iterationCount: 5)]
[Config(typeof(Config))]
public class RealDataBenchmark
{
Expand Down Expand Up @@ -172,6 +172,7 @@ public Config()
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)
Expand Down Expand Up @@ -261,7 +262,7 @@ public unsafe void RunScalarDecodingBenchmarkUTF16(string[] data, int[] lengths)
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
char[] base64 = s.ToCharArray();
char[] base64 = input16[i];
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
Expand Down Expand Up @@ -311,18 +312,16 @@ public unsafe void RunSSEDecodingBenchmarkUTF16(string[] data, int[] lengths)
throw new Exception("Error");
}
}
}


}



public unsafe void RunSSEDecodingBenchmarkWithAllocUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
//string s = FileContent[i];
byte[] base64 = input[i];
byte[] dataoutput = new byte[SimdBase64.Base64.MaximalBinaryLengthFromBase64Scalar<byte>(base64.AsSpan())];
//byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.Base64.DecodeFromBase64SSE(base64.AsSpan(), dataoutput, out bytesConsumed, out bytesWritten, false);
Expand All @@ -340,7 +339,7 @@ public unsafe void RunSSEDecodingBenchmarkWithAllocUTF16(string[] data, int[] le
for (int i = 0; i < FileContent.Length; i++)
{
string s = FileContent[i];
char[] base64 = s.ToCharArray();
char[] base64 = input16[i];
byte[] dataoutput = new byte[SimdBase64.Base64.MaximalBinaryLengthFromBase64Scalar<char>(base64.AsSpan())];
int bytesConsumed = 0;
int bytesWritten = 0;
Expand All @@ -364,11 +363,13 @@ public void Setup()
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/")
Expand All @@ -378,13 +379,15 @@ public void Setup()
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();
}

}
Expand Down

0 comments on commit 0bdd958

Please sign in to comment.