// 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; using System.Diagnostics; using System.Threading; namespace E { public class MainClass { public static int Fac(int n) { if(n > 1) { return n * Fac(n -1); } else { return 1; } } public static int CpuTime() { return (int)Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds; } public static long WallTime() { return DateTime.Now.Ticks / 10000; } public static void Load(double target) { int n = 1000000; int cpu = CpuTime(); long wall = WallTime(); int dcpu; long dwall; for(;;) { for(int i = 0; i < n; i++) { if(Fac(10) != 3628800) { Environment.Exit(1); } } Thread.Sleep(100); int cpu2 = CpuTime(); long wall2 = WallTime(); dcpu = cpu2 - cpu; dwall = wall2 - wall; n = (int)(n * ((target * dwall) / dcpu)); cpu = cpu2; wall = wall2; } } public static void Main(string[] args) { Load(0.375);; } } }