Amit
Amit

Reputation: 2130

JVM instructions for executing a set of algorithum

This more of a concept question. Wondering if any one of you have come across any way to capture instructions passed by JVM to OS while executing a set of algorithm.

The thing is if we take say performance of an application, it has way too many variables such as # of process, # of CPU's, speed of CPU, available memory etc. etc. What I am looking for is some way to abstract all those dependencies out, so basically it all boils down to the number of instructions passed by JVM and depending on other variables those instructions can be executed faster or slower.

Is there any way one can hook in such code may be native and get those information ?

I know its really abstract but not sure if I can put that in any simpler form.

Thanks

Upvotes: 3

Views: 125

Answers (1)

Joachim Sauer
Joachim Sauer

Reputation: 308021

You can't really do that.

Once upon a time you could count clock cycles and calculate the speed of a given (small) piece of code (I distinctly remember the millisecond duration of a given x86 assembler command being available in the reference I used, it was only valid for a Intel 8086 CPU, however).

But modern hardware does so many kinds of optimizations (not to speak of software optimizations) that there is no easy way to "abstract away" those things. Even the relations might be different (a calculation might be 10 times faster than memory access in architecture #1 and 20 times faster in architecture #2). The different CPU cache level sizes alone can have a huge influence in the actual speed of a piece of code.

But if you find a way, be sure to patent it and hide it away. You should be able to make a lot of money with that.

Upvotes: 1

Related Questions