Graphic Memory and CPU usage

Started by OverBlob, November 22, 2012, 12:34:49

Previous topic - Next topic

OverBlob

Hi !
Do you know if there is a way to obtain the RAM, the graphic memory and the CPU usage in LWJGL?

I thought it would be better to get it as soon as possible in order to see what uses the most resources of my computer so I can make early optimizations in my code. :)

CodeBunny

I don't know about getting GPU stats, but I can help you with CPU-side stuff.

Also, remember that your java application is being run within the JVM. As such, you can ask the JVM for certain statistics about your program.

To detect the amount of memory being used/the maximum amount of memory possible, I believe Runtime has some methods that let you detect that.

As for "CPU usage", I'm not sure how you would detect that and I really don't think it's all that useful of a statistic. You'd probably be more interested in "completion time" statistics - how long it takes your game loop to complete before sleeping. Alternatively, you may be interested in the percentage of your game loop that is not spent sleeping. For both of these figures, you'd probably use System.nanotime() in order to get the initial durations, and then do some conversions/comparisons.

princec

I think JMX beans have some tools for this.

Cas :)

OverBlob

Okay thank you guys, I'll dig in thoose ways ! :)