diff options
| author | Bond_009 <bond.009@outlook.com> | 2019-10-19 00:22:08 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2019-11-01 17:52:29 +0100 |
| commit | a245f5a0d463e132bcbb3c5871465bdb8bbec0b7 (patch) | |
| tree | 0c948c2838ea856bd596223ef4d286547aaba767 /benches/Jellyfin.Common.Benches/HexEncodeBenches.cs | |
| parent | 89a21c96c05dd89ff2d2bd5926d0f98c6ef0db9b (diff) | |
Rewrite hex encoder/decoder
Diffstat (limited to 'benches/Jellyfin.Common.Benches/HexEncodeBenches.cs')
| -rw-r--r-- | benches/Jellyfin.Common.Benches/HexEncodeBenches.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/benches/Jellyfin.Common.Benches/HexEncodeBenches.cs b/benches/Jellyfin.Common.Benches/HexEncodeBenches.cs new file mode 100644 index 000000000..e7b446cc2 --- /dev/null +++ b/benches/Jellyfin.Common.Benches/HexEncodeBenches.cs @@ -0,0 +1,29 @@ +using System; +using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Running; +using MediaBrowser.Common; + +namespace Jellyfin.Common.Benches +{ + [MemoryDiagnoser] + public class HexEncodeBenches + { + private const int N = 1000; + private readonly byte[] data; + + public HexEncodeBenches() + { + data = new byte[N]; + new Random(42).NextBytes(data); + } + + [Benchmark] + public string HexEncode() => Hex.Encode(data); + + [Benchmark] + public string BitConverterToString() => BitConverter.ToString(data); + + [Benchmark] + public string BitConverterToStringWithReplace() => BitConverter.ToString(data).Replace("-", ""); + } +} |
