Created
March 15, 2012 01:52
-
-
Save stefansedich/2041158 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Test] | |
| public void Foo() | |
| { | |
| var initialList = new List<int>(); | |
| var list1 = new List<int>(); | |
| var list2 = new List<int>(); | |
| for(var i = 0; i < 100000; i++) | |
| { | |
| initialList.Add(i); | |
| } | |
| var sw1 = Stopwatch.StartNew(); | |
| foreach(var item in initialList) | |
| { | |
| list1.Add(item); | |
| } | |
| sw1.Stop(); | |
| Console.WriteLine(sw1.Elapsed.ToString()); | |
| var sw2 = Stopwatch.StartNew(); | |
| list2.AddRange(initialList); | |
| sw2.Stop(); | |
| Console.WriteLine(sw2.Elapsed.ToString()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment