Skip to content

Instantly share code, notes, and snippets.

@stephentoub
Last active June 6, 2017 23:09
Timing repeatedly Enqueue'ing to and Dequeue'ing from a Queue<T>
using System;
using System.Diagnostics;
using System.Collections.Generic;
public class Test
{
public static void Main()
{
while (true)
{
var q = new Queue<int>();
var sw = Stopwatch.StartNew();
for (int i = 0; i < 100_000_000; i++)
{
q.Enqueue(i);
q.Dequeue();
}
Console.WriteLine(sw.Elapsed);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment