Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Text;
  5. using Wintellect.PowerCollections;
  6.  
  7. namespace ConsoleApp10
  8. {
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             const int operations = 2_000_000;
  14.             Stopwatch watch = new Stopwatch();
  15.             //List
  16.             watch.Start();
  17.             List<char> justNormalList = new List<char>();
  18.             for (int i = 0; i < operations; i++)
  19.             {
  20.                 justNormalList.Insert(i / 2, 'a');
  21.             }
  22.             watch.Stop();
  23.             Console.WriteLine(watch.Elapsed);
  24.             //BigList
  25.             watch = new Stopwatch();
  26.             watch.Start();
  27.             BigList<char> bigList = new BigList<char>();
  28.             for (int i = 0; i < operations; i++)
  29.             {
  30.                 bigList.Insert(i/2,'a');
  31.             }
  32.             watch.Stop();
  33.             Console.WriteLine(watch.Elapsed);
  34.             //StringBuilder
  35.             watch = new Stopwatch();
  36.             watch.Start();
  37.             StringBuilder builder = new StringBuilder();
  38.             for (int i = 0; i < operations; i++)
  39.             {
  40.                 builder.Insert(i / 2, 'a');
  41.             }
  42.             watch.Stop();
  43.             Console.WriteLine(watch.Elapsed);
  44.  
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement