// 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 Program { public static void Main(string[] args) { DateTime startwall = DateTime.Now; double startcpu = Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds; int t = 100; while(true) { double x = 2; for(int i = 0; i < 1000000; i++) { x = Math.Pow(Math.Sqrt(x), 2); } double deltawall = (DateTime.Now - startwall).TotalMilliseconds; double deltacpu = Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds - startcpu; double usage = deltacpu / deltawall; t = (int)(t * usage/0.5 + 0.5); Thread.Sleep(t); } } } }