public void bitblock32_pack() { for (var i = 0; i < SampleSize; i++) { var src = Random.Next <uint>(); var block = BitBlock32.Alloc(); var dst = 0u; BitParts.part32x1(src, ref block); BitParts.pack32x1(in block, ref dst); Claim.eq(dst, src); } }
public void bitpart_32x1_bench() { void bitstring() { var opname = "part32x1_bitstring"; var sw = stopwatch(false); var bs = default(BitString); for (var i = 0; i < OpCount; i++) { var src = Random.Next <uint>(); sw.Start(); bs = src.ToBitString(); sw.Stop(); } Collect((OpCount, sw, opname)); } void blockstyle() { var opname = "part32x1_block32"; var sw = stopwatch(false); BitBlock32 last = default; for (var i = 0; i < OpCount; i++) { var src = Random.Next <uint>(); sw.Start(); BitParts.part32x1(src, ref last); sw.Stop(); } Collect((OpCount, sw, opname)); } void spanstyle() { var opname = "part32x1"; var sw = stopwatch(false); Span <byte> dst = stackalloc byte[32]; for (var i = 0; i < OpCount; i++) { var src = Random.Next <uint>(); sw.Start(); BitParts.part32x1(src, dst); sw.Stop(); } Collect((OpCount, sw, opname)); } void bittest() { var opname = "part32x1_test"; var sw = stopwatch(false); Span <byte> dst = stackalloc byte[32]; for (var i = 0; i < OpCount; i++) { var src = Random.Next <uint>(); sw.Start(); part32x1_test(src, dst); sw.Stop(); } Collect((OpCount, sw, opname)); } spanstyle(); }