// 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.IO; namespace E { public class MainClass { public static void Read(int bufsiz) { long t1 = DateTime.Now.Ticks; Stream stm = new FileStream(@"C:\big.dat", FileMode.Open, FileAccess.Read); byte[] buf = new byte[bufsiz]; int n; int tot = 0; while((n = stm.Read(buf, 0, bufsiz)) > 0) { tot += n; } stm.Close(); long t2 = DateTime.Now.Ticks; Console.WriteLine("Buffer: " + bufsiz + " Time: " + (t2 - t1)/10000); } private const int REP = 3; public static void Main(string[] args) { for(int j = 0; j < REP; j++) { int bufsiz = 1; for(int i = 1; i <= 7; i++) { bufsiz *= 10; Read(bufsiz); } } } } }