Last active
November 3, 2015 21:13
-
-
Save JonRurka/88b09228922727e85554 to your computer and use it in GitHub Desktop.
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Diagnostics; | |
namespace loopBenchmark | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Stopwatch watch = new Stopwatch(); | |
watch.Start(); | |
for (int i = 0; i < 10000; i++) ; | |
watch.Stop(); | |
Console.WriteLine("for: " + watch.Elapsed.ToString()); | |
int[] intList = new int[10000]; | |
watch.Start(); | |
foreach (int i in intList) ; | |
watch.Stop(); | |
Console.WriteLine("foreach: " + watch.Elapsed.ToString()); | |
Console.ReadKey(); | |
} | |
} | |
} | |
output: | |
for: 00:00:00.0000373 | |
foreach: 00:00:00.0000565 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment