时间测试
[csharp]
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 时间测试
{
class Program
{
static void Main(string[] args)
{
int[] numbs = new int[100000];
BuildArray(numbs);
TimeSpan duration;
DisplayNumbs(numbs);
DisplayNumbs(numbs);
DisplayNumbs(numbs);
duration = Process.GetCurrentProcess().TotalProcessorTime;
Console.WriteLine("Time:" + duration.TotalSeconds);
}
public static void BuildArray(int[] numbs)
{
for (int i = 0; i < numbs.Length; i++)
{
numbs[i] = i;
}
}
public static void DisplayNumbs(int[] numbs)
{
for (int i = 0; i < numbs.Length; i++)
{
Console.Write(numbs[i] + " ");
}
}
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 时间测试
{
class Program
{
static void Main(string[] args)
{
int[] numbs = new int[100000];
BuildArray(numbs);
TimeSpan duration;
DisplayNumbs(numbs);
DisplayNumbs(numbs);
DisplayNumbs(numbs);
duration = Process.GetCurrentProcess().TotalProcessorTime;
Console.WriteLine("Time:" + duration.TotalSeconds);
}
public static void BuildArray(int[] numbs)
{
for (int i = 0; i < numbs.Length; i++)
{
numbs[i] = i;
}
}
public static void DisplayNumbs(int[] numbs)
{
for (int i = 0; i < numbs.Length; i++)
{
Console.Write(numbs[i] + " ");
}
}
}
}
-------------------封装的Timing类----------------------------------------------------------------------------------------------------------------------
[csharp]
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Timing类
{
class Program
{
static void Main(string[] args)
{
int[] numbs = new int[100000];
BuildArray(numbs);
Timing test = new Timing();
test.StartTime();
DisplayNumbs(numbs);
test.StopTime();
Console.WriteLine("Time:" + test.Result());
}
public static void BuildArray(int[] numbs)
{
for (int i = 0; i < numbs.Length; i++)
{
numbs[i] = i;
}
}
public static void DisplayNumbs(int[] numbs)
{
for (int i = 0; i < numbs.Length; i++)
{
补充:软件开发 , C# ,