Beispiel #1
0
        static void Main(string[] args)
        {
            Phonedata.PhoneData pd = new Phonedata.PhoneData("phone.dat");
            string output;

            output = pd.Lookup("14794299760").ToString();
            Console.WriteLine(output);
            Console.ReadKey();

            /*
             * 1344710142
             * 1344711000
             */
        }
Beispiel #2
0
        static void Benchmark_test()
        {
            Phonedata.PhoneData pd  = new Phonedata.PhoneData("phone.dat");
            DateTime            dt1 = DateTime.Now;

            Parallel.ForEach(s, (i) =>
            {
                pd.Lookup(i);
            });
            //foreach (var item in s)
            //{
            //    pd.Lookup(item);
            //}
            DateTime dt2 = DateTime.Now;

            Console.WriteLine("并行计算 {0}个手机号码的查找,用时: {1}毫秒。\n", s.Length, (dt2 - dt1).TotalMilliseconds);
        }