using System.Collections;
using System.Collections.Generic;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Helpers;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Toolchains.InProcess.Emit;
using BenchmarkDotNet.Loggers;
using Perfolizer.Horology;
[assembly: System.Diagnostics.Debuggable(isJITTrackingEnabled: false, isJITOptimizerDisabled: false)]
BenchmarkRunner.Run<Benchmark>(DefaultConfig.Instance
.WithToolchain(new InProcessEmitToolchain(
timeout: TimeSpan.FromSeconds(30),
.WithIterationTime(TimeInterval.FromMilliseconds(20)))
.AddLogger(new ConsoleLogger(unicodeSupport: true, ConsoleLogger.CreateGrayScheme()))
.WithOptions(ConfigOptions.DisableLogFile));
public long unixTimeStamp { get; set; }
public string unixTimeStampHex { get; set; }
[Params(1, 2, 3, 4, 5, 6, 7, 8, 9)]
Random rnd = new Random();
unixTimeStamp = rnd.Next(-6213559, 25340230);
unixTimeStampHex = unixTimeStamp.ToString("X4");
Console.WriteLine(unixTimeStampHex);
return ParseHexFast(unixTimeStampHex);
return ParseHexFast2(unixTimeStampHex);
public static int ParseHexFast2(in string s) { return ParseHexFast(s.AsSpan()); }
public static int ParseHexFast2(in ReadOnlySpan<char> s)
for (int i = 0; i < s.Length; i++)
y = (y * 16) + ((int)hexchar_hashtable[s[i]]);
public static int ParseHexFast(in string s) { return ParseHexFast(s.AsSpan()); }
public static int ParseHexFast(in ReadOnlySpan<char> s)
for (int i = 0; i < s.Length; i++)
y = (y * 16) + (hexchar_dict[s[i]]);
public static long ParseHexLongFast(in string s) { return ParseHexFast(s.AsSpan()); }
public static long ParseHexLongFast(in ReadOnlySpan<char> s)
for (int i = 0; i < s.Length; i++)
y = (y * 16) + (hexchar_dict[s[i]]);
private static System.Collections.Hashtable hexchar_hashtable = new System.Collections.Hashtable()
{ '0', 0 }, { '1', 1 }, { '2', 2 }, { '3', 3 }, { '4', 4 }, { '5', 5 }, { '6', 6 }, { '7', 7 },
{ '8', 8 }, { '9', 9 }, { 'a', 10 }, { 'A', 10 }, { 'b', 11 }, { 'B', 11 }, { 'c', 12 },
{ 'C', 12 }, { 'd', 13 }, { 'D', 13 }, { 'e', 14 }, { 'E', 14 }, { 'f', 15 }, { 'F', 15 }
private static Dictionary<char, int> hexchar_dict = new Dictionary<char, int>()
{ '0', 0 }, { '1', 1 }, { '2', 2 }, { '3', 3 }, { '4', 4 }, { '5', 5 }, { '6', 6 }, { '7', 7 },
{ '8', 8 }, { '9', 9 }, { 'a', 10 }, { 'A', 10 }, { 'b', 11 }, { 'B', 11 }, { 'c', 12 },
{ 'C', 12 }, { 'd', 13 }, { 'D', 13 }, { 'e', 14 }, { 'E', 14 }, { 'f', 15 }, { 'F', 15 }