.NET 5和java 8性能对比,同样是发布以后的情况对比

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的三倍

 

 

 

posted on 2022-01-11 22:18  topguntopgun  阅读(875)  评论(2编辑  收藏  举报

导航