<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      值類型和引用類型在hashtable里面存取的性能比較

      首先定義兩個類:
       1    public interface ITest
       2    {
       3        void M();
       4    }

       5    public class Test1:ITest
       6    {
       7        public void M()
       8        {
       9        }

      10    }

      11   class Test
      12        {
      13            public Test()
      14            {
      15            }

      16        }
       首先,測試設置的速度hashtable.add()
       1static void Main(string[] args)
       2        {          
       3            Hashtable table = new Hashtable();
       4
       5            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
       6            stopWatch.Start();
       7            for (int i = 0; i < CompareCount; i++)
       8            {
       9                table.Add(i,new Test());
      10            }

      11            stopWatch.Stop();
      12            
      13            for (int i = 0; i < CompareCount; i++)
      14            {
      15                Test o = table[i] as Test;
      16            }

      17           
      18            string t1 = stopWatch.ElapsedTicks.ToString();
      19          
      20            Hashtable table1 = new Hashtable();
      21            System.Diagnostics.Stopwatch stopWatch1 = new System.Diagnostics.Stopwatch();
      22            stopWatch1.Start();
      23            for (int i = 0; i < CompareCount; i++)
      24            {
      25                table1.Add(i, i);
      26            }

      27            stopWatch1.Stop();
      28        
      29            for (int i = 0; i < CompareCount; i++)
      30            {
      31                int o = (int)table1[i];
      32            }

      33           
      34            string t2 = stopWatch1.ElapsedTicks.ToString();
      35            Hashtable table2 = new Hashtable();
      36            System.Diagnostics.Stopwatch stopWatch2 = new System.Diagnostics.Stopwatch();
      37            stopWatch2.Start();
      38            for (int i = 0; i < CompareCount; i++)
      39            {
      40                ITest test2 = new Test1();
      41                table2.Add(i,test2);
      42            }

      43
      44            stopWatch2.Stop();
      45            for (int i = 0; i < CompareCount; i++)
      46            {
      47                ITest o = table2[i] as ITest;
      48            }

      49           
      50            string t3 = stopWatch2.ElapsedTicks.ToString();
      51            Console.WriteLine(t1);
      52            Console.WriteLine(t2);
      53            Console.WriteLine(t3);
      54            Console.WriteLine(((double)Convert.ToInt64(t1)/Convert.ToInt64(t2)).ToString());
      55            Console.WriteLine(((double)Convert.ToInt64(t3) / Convert.ToInt64(t2)).ToString());
      56            Console.Read();
      57            
      58        }
      測試獲取的代碼
       1static void Main(string[] args)
       2        {          
       3            Hashtable table = new Hashtable();
       4         
       5            for (int i = 0; i < CompareCount; i++)
       6            {
       7                table.Add(i,new Test());
       8            }

       9            
      10            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
      11            stopWatch.Start();
      12            for (int i = 0; i < CompareCount; i++)
      13            {
      14                Test o = table[i] as Test;
      15            }

      16            stopWatch.Stop();
      17            string t1 = stopWatch.ElapsedTicks.ToString();
      18          
      19            Hashtable table1 = new Hashtable();
      20           
      21            for (int i = 0; i < CompareCount; i++)
      22            {
      23                table1.Add(i, i);
      24            }

      25            
      26            System.Diagnostics.Stopwatch stopWatch1 = new System.Diagnostics.Stopwatch();
      27            stopWatch1.Start();
      28            for (int i = 0; i < CompareCount; i++)
      29            {
      30                int o = (int)table1[i];
      31            }

      32            stopWatch1.Stop();
      33            string t2 = stopWatch1.ElapsedTicks.ToString();
      34            Hashtable table2 = new Hashtable();
      35            
      36            for (int i = 0; i < CompareCount; i++)
      37            {
      38                ITest test2 = new Test1();
      39                table2.Add(i,test2);
      40            }

      41            
      42            System.Diagnostics.Stopwatch stopWatch2 = new System.Diagnostics.Stopwatch();
      43            stopWatch2.Start();
      44            for (int i = 0; i < CompareCount; i++)
      45            {
      46                ITest o = table2[i] as ITest;
      47            }

      48            stopWatch2.Stop();
      49            string t3 = stopWatch2.ElapsedTicks.ToString();
      50            Console.WriteLine(t1);
      51            Console.WriteLine(t2);
      52            Console.WriteLine(t3);
      53            Console.WriteLine(((double)Convert.ToInt64(t1)/Convert.ToInt64(t2)).ToString());
      54            Console.WriteLine(((double)Convert.ToInt64(t3) / Convert.ToInt64(t2)).ToString());
      55            Console.Read();
      56            
      57        }


      測試結果 

      Add

      1)  調試(1)

      數據類型

      循環次數

      執行時間

      執行時間比例

      int

      100000

      227960

      1

      class

      100000

      138122

      0.6059

      Interface

      100000

      103693

      0.4549

       





       
      調試(2

      數據類型

      循環次數

      執行時間

      執行時間比例

      int

      100000

      282564

      1

      class

      100000

      156588

      0.5542

      Interface

      100000

      148623

      0.5230






      2) 

         運行(1)

      數據類型

      循環次數

      執行時間

      執行時間比例

      int

      100000

      155927

      1

      class

      100000

      191537

      1.2284

      Interface

      100000

      127647

      0.8186

          

       



       
      運行(2)   

      數據類型

      循環次數

      執行時間

      執行時間比例

      int

      100000

      151806

      1

      class

      100000

      222375

      1.4649

      Interface

      100000

      256467

      1.6894

         





      運行
      (3)

      數據類型

      循環次數

      執行時間

      執行時間比例

      int

      100000

      99465

      1

      class

      100000

      235016

      2.3628

      Interface

      100000

      201519

      2.0260

       

       





      從上面幾個表可以得出,在向
      Hashtable里面添加數據的時候,當value為值類型的時候最快,interface次之,class

       

      2. 查詢

        

      1.       調試(1)

      數據類型

      循環次數

      執行時間

      執行時間比例

      int

      100000

      52360

      1

      class

      100000

      71250

      1.3608

      Interface

      100000

      291566

      5.5685

       

      2.      



      調試
      (2)

      數據類型

      循環次數

      執行時間

      執行時間比例

      int

      100000

      53645

      1

      class

      100000

      55679

      1.0379

      Interface

      100000

      310780

      5.7932

       





        運行
      (1)

      數據類型

      循環次數

      執行時間

      執行時間比例

      int

      100000

      53013

      1

      class

      100000

      55414

      1.0453

      Interface

      100000

      282835

      5.3352






        運行
      (2)

      數據類型

      循環次數

      執行時間

      執行時間比例

      int

      100000

      53647

      1

      class

      100000

      66768

      1.2446

      Interface

      100000

      204599

      3.8138






        在查詢哈希表的時候,
      int最快,class次之,interface比較慢

      posted @ 2006-10-18 17:46  Robin Zhang  閱讀(2784)  評論(8)    收藏  舉報
      主站蜘蛛池模板: 亚洲国产成人精品女久久| 欧美裸体xxxx极品| 亚洲国产精品成人av网| 少妇高清一区二区免费看| 亚洲成在人线在线播放无码| 里番全彩爆乳女教师| 无码抽搐高潮喷水流白浆| 久久国产精品福利一区二区三区 | 亚洲精品一区二区三区小| 精品偷拍被偷拍在线观看| 亚洲一区二区精品另类| 国产欧美另类久久久精品不卡| 东北女人毛多水多牲交视频| 阳泉市| 综合区一区二区三区狠狠| 丰满无码人妻热妇无码区| 国产乱子伦一区二区三区四区五区| 熟女视频一区二区三区嫩草| 国产精品色呦呦在线观看| 色国产视频| 亚洲成av人最新无码不卡短片| 亚洲精品一区三区三区在| 亚洲gv猛男gv无码男同| 国产精品一区二区小视频| 婷婷五月综合丁香在线| 精品人妻伦九区久久aaa片| 人禽无码视频在线观看| 99在线精品国自产拍中文字幕 | 日本高清中文字幕免费一区二区| 狠狠干| 亚洲国产日韩A在线亚洲| 国产精品中文字幕久久| 99久久99久久久精品久久| 国产日韩欧美亚洲精品95| 国产又色又爽又黄的在线观看| 亚洲日本中文字幕天天更新| 丁香婷婷无码不卡在线| 日韩V欧美V中文在线| 国内自拍小视频在线看| 人妻系列无码专区无码中出| 精品久久精品午夜精品久久|