Jump to content
  • Advertisement
Sign in to follow this  
zappsweden

[java] How Can You Determine CPU Speed (MHz) During Runtime?

This topic is 4705 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
That information might be too low level to get using java. According to the exchange here: Measure mobiles CPU, "CPU cycles and processor power are meaningless since Java doesn't run directly on the hardware.", "You can only measure java VM performance. Other things can't be measured from within java"


As an aside, I wonder if the shmoove in that exchange is the same shmoove that hangs out here?

Share this post


Link to post
Share on other sites
I don't know that much Java so ignore me if I'm wrong. :)

Can Java speak to libs/dlls? Can you use something written in C++ in Java? If you can you could create something in C++ that gets the speed and returns it to the java object.

Share this post


Link to post
Share on other sites
You can use libraries with java with Sytem.loadLibrary("<name>");
There's also JNI, so you can wrap a C++ method that does the trick with a JNI one, returning the information for the JVM.

Son Of Cain

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What for? That kind of information is totally useless for games. Well, actually its useless for any kind of application except diagnostic software.

Share this post


Link to post
Share on other sites
Well, it is complicated and has to to with me using passive rendering and getting problem when scrolling. Since the Repaint is handled in a different thread than my event thread, scrolling get too fast and I get strange side effects. I solved that problem by limiting the scroll speed but since someone could be sitting with 400 MHz and someone else with 3 GHz I would want to vary the scroll speed accordingly and then avoiding the low spec user not to get buggy crappy software.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Why passive rendering? Its not usable for games.

And uhm... what you want is some throtteling code, which adjusts accordingly to the time spend per frame. The cpu speed wouldnt help much, since the bottleneck could be elsewhere (eg some slow integrated intel graphics chipset on a 2ghz machine is slower than some 500mhz machine with a geforce2 [well, for games anyways]).

For that you have basically two options the first one is using 1.5 nanoTime (or the hidden 1.4.2 hiperf timer) or the rather bad default timer. The former is accurate enough for being used directly and the other one (if you need 1.4 compatibility) needs some tricks. You can find some example code here:

System.nanoTime()
http://www.javagaming.org/forums/index.php?topic=7579.msg66862#msg66862

System.currentTimeMillis()
http://www.javagaming.org/forums/index.php?topic=11640.msg93602#msg93602

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!