public static void Test_hashMap_Comparison(int n) { Stopwatch watch = new Stopwatch(); Stopwatch watch2 = new Stopwatch(); HashMap <string, string> hashOp = new HashMap <string, string>(n * 2); HashMapInFile <string, string> hashHDD = new HashMapInFile <string, string>(n * 2); List <string> names = new List <string>(n); for (int i = 0; i < n; i++) { string name = RandomName(10); names.Add(name); hashOp.InsertNode(name, name); hashHDD.InsertNode(name, name); } //names.Add(RandomName(10)); long sumOp = 0; long sumHDD = 0; foreach (var name in names) { watch.Start(); hashOp.Get(name); watch.Stop(); sumOp += watch.ElapsedMilliseconds; watch.Start(); hashHDD.Get(name); watch.Stop(); sumHDD += watch.ElapsedMilliseconds; } Console.WriteLine("{0, -10} {1, -20} {2, -20}", n, sumOp / n + " ms", sumHDD / n + " ms"); }
public static void Test_File_hashMap_V2(int n) { Stopwatch watch = new Stopwatch(); Console.WriteLine("\n Išorinėje atmintyje maišos lentelėje dvigubu heshavimu paieška\n"); HashMapInFile <string, string> hash = new HashMapInFile <string, string>(n * 2); List <string> names = new List <string>(n); for (int i = 0; i < n; i++) { string name = RandomName(10); names.Add(name); hash.InsertNode(name, name); } //names.Add(RandomName(10)); long sum = 0; foreach (var name in names) { string surastas; watch.Start(); surastas = hash.Get(name); watch.Stop(); Console.WriteLine(surastas == null ? "nerastas: " + name : "rastas: " + name); sum += watch.ElapsedMilliseconds; } Console.WriteLine("vidutinis paieškos laikas : " + sum / n + " ms"); //hash.Display(); }