NCrontab Performance Test

CSharp · Console

/Program.cs

using System;
using System.Diagnostics;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		var cron = NCrontab.Advanced.CrontabSchedule.Parse("0 0 1 1 * 2016", NCrontab.Advanced.Enumerations.CronStringFormat.WithYears);
		var date = new System.DateTime(year: 2016, month: 1, day: 1, hour: 0, minute: 0, second: 0);
		
		int[] testArray = new int[1000000];
		List<int> testList = new List<int>(1000000);
		
		
		var stopWatch = new Stopwatch();
		stopWatch.Start();
		for (int i = 0; i < testList.Count;i++)
		{
			var s = 1;
		}
		stopWatch.Stop();
		Console.WriteLine("LIST FOR      " + stopWatch.Elapsed);
		
		
		stopWatch = new Stopwatch();
		stopWatch.Start();
		foreach (int i in testList)
		{
			var d = 1;
		}
		stopWatch.Stop();
		Console.WriteLine("LIST FOREACH  " + stopWatch.Elapsed);
				
		
		stopWatch = new Stopwatch();
		stopWatch.Start();
		for (int i = 0; i < testArray.Length;i++)
		{
			var f = 1;
		}
		stopWatch.Stop();
		Console.WriteLine("ARRAY FOR     " + stopWatch.Elapsed);
		
		
		stopWatch = new Stopwatch();
		stopWatch.Start();
		foreach (int i in testArray)
		{
			var h = 1;
		}
		stopWatch.Stop();
		Console.WriteLine("ARRAY FOREACH " + stopWatch.Elapsed);
	}
}
;