1、電腦配置,最近總是糾結用java還是.NETCORE,測試一下性能

2、測試循環100億次計算時間差
//java public static void main(String[] args) { double c =0; long a = new Date().getTime(); for (Long i=0L;i<100_0000_0000L;i++) c+=i; long b = new Date().getTime(); double d = (b - a) ; System.out.println(d); }
//c#代碼
static void Main(string[] args)
{
double cc = 0;
var f = new Stopwatch();
f.Start();
cc = 0;
for (Int64 i = 0; i < 100_0000_0000; i++)
{
cc = cc + i;
}
f.Stop();
Console.WriteLine($"時間:{f.Elapsed.TotalMilliseconds}");
Console.ReadLine();
}
發布以后測試,java是28秒,c#是12秒左右,.NET 5的性能是java8的三倍


