在Mac上,处理器运行速度比Windows计算机上更快的Java代码? [英] Java code running faster on Mac with slower processor than on my Windows computer?

查看:300
本文介绍了在Mac上,处理器运行速度比Windows计算机上更快的Java代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到任何答案,所以我想在这里问.

I couldnt find any answer to this so I thought I'd ask in here.

我有一台MacBook,它具有2.50 GHz @Intel®Core™i7-4870HQ CPU和一台装有i7-4790K 4ghz cpu的Windows计算机.

I have a MacBook with a Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz and a Windows computer with an i7-4790K 4ghz cpu.

我写了一些Java代码,它们在两台机器上运行6个线程,并执行一个长时间运行的任务,并通过一个普通的for循环遍历ArrayList,每次循环都是相同的,只是每次ArrayList变短了一点,所以时间该方法每次运行时自然会变短.但是,在我的MacBook和Windows计算机上同时运行它,他们运行代码所需的时间明显不同,并且我的MacBook在大约12-13分钟的时间里每次赢得大约1分钟或更长的时间就赢得了胜利(此时)运行该方法.

I wrote some Java code which is running 6 threads on both machines with a long running task iterating over an ArrayList with a normal for-loop which is the same every time except each time the ArrayList gets a little bit shorter so the time naturally becomes shorter each time the method runs. However, running it on both my MacBook and Windows computer there is a noticable difference in the time it takes for them to run the code and my MacBook is winning each time with around 1 minute or more out of the around 12-13 minutes it takes to run the method (at this point).

两个cpus都没有以100%的速度运行,并且两台计算机都有大量未使用的RAM.

Neither of the cpus are running at 100% and both computers have a lot of unused RAM.

希望您能提供帮助,让我知道是否可以提供更多信息. :)

I hope you can help and let me know if there is a way I can provide more information. :)

推荐答案

我将从检查每台计算机上的内存规格开始.通常,Apple倾向于在其机器中放置最快的RAM.

I would start by checking the specs of the memory on each machine. As a rule Apple tends to put the fastest RAM it can in its machines.

如果不是RAM,则应检查JVM的配置是否相同:如果Windows PC上的堆空间较小,则可能是在浪费额外的时间进行垃圾收集.

If it's not the RAM, you should check that the JVM is configured the same: if the heap space is smaller on the Windows PC, it's probably spending that extra minute garbage collecting.

除此之外,它必须像在Mac上进行上下文切换一样快,但是我从未听说有人建议OS X本质上比Windows快.

Other than that, it must be something like context switching being faster on the Mac, but I've never heard before anybody suggesting that OS X is intrinsically faster than Windows.

这篇关于在Mac上,处理器运行速度比Windows计算机上更快的Java代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆