Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (622)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (674)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  CPU usage monitoring  (Read 1929 times)
0 Members and 1 Guest are viewing this topic.
Offline dranonymous

Junior Devvie

Hoping to become a Java Titan someday!

« Posted 2004-06-18 23:06:00 »

I've done no research, so I'm open to be flamed. Smiley

Is there any way to detect what the cpu is doing while your program is running?  My thought is that I could run a 'stress test' on the computer the program is running on.  Depending on the results, it would set program options differently at runtime.  I could turn off music or load lower quality images, etc.

Any info?
« Reply #1 - Posted 2004-06-19 00:32:45 »

Google for profilers. Java actually has one itself (hotspot profiler) - try running your app with -xprof parameter. If you're using eclipse there's a really nice profiler plugin for it.
Offline dranonymous

Junior Devvie

Hoping to become a Java Titan someday!

« Reply #2 - Posted 2004-06-19 01:03:22 »

Thanks for the info on the -Xprof.  I have started using that just recently.

I'm actually trying to get at the info in the application itself.  In pseudo code, it might look like this -

if(CPU.getActivity() >= 0.60f) {

if(CPU.getActivity() <= 0.20f) {

In the 'code' CPU.getActivity would return the processors current loading (think task manager in Windows, or ps or top for linux) as a float 0 being not loaded 1 being fully loaded.

I've used a similar technique before.  When network traffic got very high, it would start sucking the CPU.  In the graphics thread, I checked the loading and if it was too high, I skipped the draw for that frame.  This was in a C# program. (Don't flog me for not using java!)

Am I asking for the impossible?

Aaron R>
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

« JGO Spiffy Duke »

Medals: 579
Projects: 3
Exp: 16 years

Eh? Who? What? ... Me?

« Reply #3 - Posted 2004-06-19 06:15:09 »

You need to write a bit of JNI to do this.

Cas Smiley

Offline Abuse

JGO Knight

Medals: 34

falling into the abyss of reality

« Reply #4 - Posted 2004-06-26 11:15:57 »


Is there any way to detect what the cpu is doing while your program is running?

Thats easy, its running your program =)

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here!
Offline elias

Senior Devvie

« Reply #5 - Posted 2004-06-26 13:30:25 »

I don't know why you want to measure CPU load instead of something more relevant to your game, like FPS. FPS can easily be measured in-game, so why not do something like:

if (fps < 60) {

- elias

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

basil_ (32 views)
2015-09-30 17:04:40

shadowstryker (16 views)
2015-09-29 15:55:06

TheSpaceHedgehog (22 views)
2015-09-29 01:58:48

GamerC4 (45 views)
2015-09-24 21:10:38

GamerC4 (66 views)
2015-09-24 21:09:48

htuy (21 views)
2015-09-24 04:57:24

htuy (30 views)
2015-09-24 04:56:35

htuy (20 views)
2015-09-24 04:56:09

htuy (21 views)
2015-09-24 04:47:33

Roquen (58 views)
2015-09-21 12:54:28
Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!