static void Benchmark_test() { Phonedata.Phonedata pd = new Phonedata.Phonedata("phone.dat"); List <string> data = Program.Data; DateTime dt1 = DateTime.Now; Parallel.ForEach(data, (i) => { pd.Lookup(i); }); DateTime dt2 = DateTime.Now; Console.WriteLine("并行计算 100000个手机号码的查找,用时: {0}毫秒。\n", (dt2 - dt1).TotalMilliseconds); }
static void Main(string[] args) { Phonedata.Phonedata pd = new Phonedata.Phonedata("phone.dat"); string output; if (args.Length == 1) { output = pd.Lookup(args[0]).ToString(); Console.WriteLine(output); } else { Console.WriteLine("Usage:\t\n\tphonedatacmd.exe PhoneNumber\n"); } }