Example #1
0
 void bm_and_16x16_bench_run(SystemCounter counter = default)
 {
     //var sw = stopwatch(false);
     for (var i = 0; i < OpCount; i++)
     {
         var x = Random.BitMatrix(n16);
         var y = Random.BitMatrix(n16);
         counter.Start();
         var result = x & y;
         counter.Stop();
     }
     Benchmark("bm_and_16x16", counter);
 }
Example #2
0
        /// <summary>
        /// Performs no allocation during the benchmark period
        /// </summary>
        /// <param name="sw">The counter</param>
        void bm_xor_32x32_bench_noalloc(SystemCounter sw = default)
        {
            var opname = "bm_xor_32x32";
            var last   = BitMatrix32.Alloc();

            for (var i = 0; i < OpCount; i++)
            {
                var A = Random.BitMatrix(n32);
                var B = Random.BitMatrix(n32);
                sw.Start();
                BitMatrix.xor(in A, in B, ref last);
                sw.Stop();
            }

            Benchmark(opname, sw);
        }
Example #3
0
        /// <summary>
        /// Performs allocation during each operation of the benchmark period
        /// </summary>
        /// <param name="sw">The counter</param>
        void bm_xor_16x16_bench_alloc(SystemCounter sw = default)
        {
            var opname = "bm_xor_16x16_alloc";
            var last   = default(BitMatrix16);

            for (var i = 0; i < OpCount; i++)
            {
                var A = Random.BitMatrix(n16);
                var B = Random.BitMatrix(n16);
                sw.Start();
                last = BitMatrix.xor(in A, in B);
                sw.Stop();
            }

            Benchmark(opname, sw);
        }
Example #4
0
        void add_bench <T>(SystemCounter subject = default, SystemCounter compare = default)
            where T : unmanaged
        {
            var last  = default(T);
            var asmop = AsmOps.Add <T>();

            for (var i = 0; i < OpCount; i++)
            {
                var a = Random.Next <T>();
                var b = Random.Next <T>();
                subject.Start();
                last = asmop(a, b);
                subject.Stop();

                compare.Start();
                last = gmath.add(a, b);
                compare.Stop();
            }

            Benchmark($"add{moniker<T>()}_asm", subject);
            Benchmark($"add{moniker<T>()}", compare);
        }
Example #5
0
        void add_bench <T>(SystemCounter subject = default, SystemCounter compare = default)
            where T : unmanaged
        {
            var last = default(Vector128 <T>);
            var del  = new Asm128BinOp <T>(ginx.add);

            for (var i = 0; i < OpCount; i++)
            {
                var a = Random.CpuVector128 <T>();
                var b = Random.CpuVector128 <T>();
                subject.Start();
                last = del(a, b);
                subject.Stop();

                var c = Random.CpuVector128 <T>();
                var d = Random.CpuVector128 <T>();
                compare.Start();
                last = ginx.add(c, d);
                compare.Stop();
            }

            Benchmark($"add{moniker<T>()}_del", subject);
            Benchmark($"add{moniker<T>()}", compare);
        }