// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace Pause { public class Pause { public static void Main(string[] args) { Random rng = new Random(); object[] a = new object[2000000]; int n0 = 0; int n16 = 0; int n100 = 0; int n250 = 0; int nbig = 0; long t1 = DateTime.Now.Ticks; long tstart = t1; for(int i = 0; i < 200000000; i++) { int ix = rng.Next(a.Length); a[ix] = new object(); //long t2 = DateTime.Now.Ticks; long t2 = (i%100==0) ? DateTime.Now.Ticks : t1; if(t2 - t1 == 0) { n0++; } else if(t2 - t1 <= 16*10000) { n16++; } else if(t2 - t1 <= 100*10000) { n100++; } else if(t2 - t1 <= 250*10000) { n250++; } else { nbig++; } t1 = t2; } long tend = t1; Console.WriteLine("17-100 ms: " + n100); Console.WriteLine("101-250 ms: " + n250); Console.WriteLine("251+ ms: " + nbig); Console.WriteLine("total ms: " + (tend - tstart)/10000); } } }