using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
using System; using System.Collections. Generic ; using System.Diagnostics; public class HashSetIterationPerformance { public const int MaxItemsCount = 10000000; public const int RepeatIterations = 200; public static TimeSpan MeasureIterationTime(HashSet< int > hashSet) { var stopwatch = new Stopwatch(); stopwatch.Start(); for ( int i = 0; i < RepeatIterations; ++i) foreach ( var x in hashSet) { // Do nothing } return new TimeSpan (stopwatch.Elapsed.Ticks / RepeatIterations); } public static void Main( string [] args) { var hashSet = new HashSet< int >(); hashSet.Add(0); Console .WriteLine( "Usual scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); hashSet = new HashSet< int >(); // - : [0..MaxItemsCount) for ( int i = 0; i < MaxItemsCount; ++i) { hashSet.Add(i); } // , for ( int i = 1; i < MaxItemsCount; ++i) { hashSet.Remove(i); } Console .WriteLine( "Add/Remove scenario. Iteration time: {0}" , MeasureIterationTime(hashSet)); } } * This source code was highlighted with Source Code Highlighter .
Usual scenario. Iteration time: 00:00:00.0000032
Add/Remove scenario. Iteration time: 00:00:00.0468619
Source: https://habr.com/ru/post/90217/