You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/benches/Jellyfin.Common.Benches/HexEncodeBenches.cs

33 lines
791 B

using System;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using MediaBrowser.Common;
namespace Jellyfin.Common.Benches
{
[MemoryDiagnoser]
public class HexEncodeBenches
{
5 years ago
private byte[] _data;
5 years ago
[Params(0, 10, 100, 1000, 10000, 1000000)]
public int N { get; set; }
[GlobalSetup]
public void GlobalSetup()
{
5 years ago
_data = new byte[N];
new Random(42).NextBytes(_data);
}
[Benchmark]
5 years ago
public string HexEncode() => Hex.Encode(_data);
[Benchmark]
5 years ago
public string BitConverterToString() => BitConverter.ToString(_data);
[Benchmark]
5 years ago
public string BitConverterToStringWithReplace() => BitConverter.ToString(_data).Replace("-", "");
}
}