Exemplo n.º 1
0
        public unsafe void xxHashBenchmark()
        {
            var rng = new Random(42);
            var len = 10;
            var mem = BufferPool.Retain(len);
            var ptr = (byte *)mem.Pointer;

            rng.NextBytes(mem.GetSpan());
            var  count = 50_000_000;
            uint hash  = 0;

            using (Benchmark.Run("xxHash", count))
            {
                for (int i = 0; i < count; i++)
                {
                    hash = XxHash.CalculateHash(ptr, len);
                }
            }
            Benchmark.Dump();
            Console.WriteLine(hash);
        }
Exemplo n.º 2
0
        public unsafe void xxHashIncrementalBenchmark2()
        {
            var rng = new Random(42);
            var len = 8;
            var mem = BufferPool.Retain(len);
            var ptr = (byte *)mem.Pointer;

            rng.NextBytes(mem.GetSpan());
            var count = 100_000_000;
            var sum   = 0UL;

            uint digest = 0;

            using (Benchmark.Run("xxHash", count))
            {
                for (int i = 0; i < count; i++)
                {
                    digest = XxHash.CalculateHash(ptr, len, digest);
                }
            }
            Benchmark.Dump();
            Console.WriteLine(digest);
        }