LIST FOR 00:00:00.0000980
LIST FOREACH 00:00:00.0000007
ARRAY FOR 00:00:00.0028450
ARRAY FOREACH 00:00:00.0051233
Run Code Online (Sandbox Code Playgroud)
我一直用数组来制作性能较重的东西,但列表似乎要快得多。
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 …Run Code Online (Sandbox Code Playgroud)