Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Text;
- using Wintellect.PowerCollections;
- namespace ConsoleApp10
- {
- class Program
- {
- static void Main()
- {
- const int operations = 2_000_000;
- Stopwatch watch = new Stopwatch();
- //List
- watch.Start();
- List<char> justNormalList = new List<char>();
- for (int i = 0; i < operations; i++)
- {
- justNormalList.Insert(i / 2, 'a');
- }
- watch.Stop();
- Console.WriteLine(watch.Elapsed);
- //BigList
- watch = new Stopwatch();
- watch.Start();
- BigList<char> bigList = new BigList<char>();
- for (int i = 0; i < operations; i++)
- {
- bigList.Insert(i/2,'a');
- }
- watch.Stop();
- Console.WriteLine(watch.Elapsed);
- //StringBuilder
- watch = new Stopwatch();
- watch.Start();
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < operations; i++)
- {
- builder.Insert(i / 2, 'a');
- }
- watch.Stop();
- Console.WriteLine(watch.Elapsed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement