Ejemplo n.º 1
0
        private void btnMemetRandom_Click(object sender, EventArgs e)
        {
            Random rnd = new Random();
            int    val = rnd.Next(0, 255);
            var    t0  = GetTimeMs();

            Util2.memset(srcBuf, val, bytes);
            Log($"memset with ({val}) {GB:f3}GB  : {GetTimeMs()-t0:f3}ms");
        }
Ejemplo n.º 2
0
        private void btnAlloc_Click(object sender, EventArgs e)
        {
            var t0 = GetTimeMs();

            bytes = (long)numMegabyte.Value * 1024 * 1024;

            if (srcBuf != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(srcBuf);
            }
            srcBuf = Marshal.AllocHGlobal((IntPtr)bytes);
            Util2.memset(srcBuf, 0, bytes);

            if (dstBuf != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(dstBuf);
            }
            dstBuf = Marshal.AllocHGlobal((IntPtr)bytes);
            Util2.memset(dstBuf, 0, bytes);

            Log($"Alloc {GB:f3}GB Finished - {GetTimeMs()-t0:f3}ms");
        }