- Jul 11, 2004
- 21,867
- 7
- 81
I come from a EE background. I've been programming firmware on embedded microprocessors in assembly and C. I've been working on systems in the 8MHz - 24MHz range. I've been writing firmware which means that my code is the only thing running on the processor, there is no OS. This makes it really easy to understand the performance of my software because I can literally count cycles. "This routine looks like it takes about 500 cycles, it needs to run every 20,000 cycles, we're good!"
A couple of years ago, I got a 72MHz embedded board and I felt like I had unlimited processing power. So, if that gives you an idea.
Now, times have changed. I'm writing Java code which runs on the Java Virtual Machine. I'm running on a computer with 4 cores at 3GHz, with a multitasking OS. I have absolutely no idea how much power this equates to.
To give an example. I was writing a loop which iterated over 1 million integers and did about 10 lines of conditional logic for each. I was very concerned about the performance since, in my mind, this was an absolutely huge loop. I asked somebody at work about it and they said something like "its only a million integers, its incredibly fast, don't worry about it". Turns out they're absolutely right. The performance impact is nearly negligible to my program's performance.
So to break down my lack of understanding:
- I cannot translate lines of code into CPU cycles, because I'm writing Java
- Say I knew the cycle count for the JVM, I don't know how this translates into real cycle count on the underlying CPU.
- Say I knew the real cycle count, I don't understand what that would actually mean since I'm in a multitasking OS
Can anybody offer some insight? I don't need hugely detailed explanations. Ultimately I only need to understand basic performance (eg. can I loop over 1 million integers and not slow down the program?).
A couple of years ago, I got a 72MHz embedded board and I felt like I had unlimited processing power. So, if that gives you an idea.
Now, times have changed. I'm writing Java code which runs on the Java Virtual Machine. I'm running on a computer with 4 cores at 3GHz, with a multitasking OS. I have absolutely no idea how much power this equates to.
To give an example. I was writing a loop which iterated over 1 million integers and did about 10 lines of conditional logic for each. I was very concerned about the performance since, in my mind, this was an absolutely huge loop. I asked somebody at work about it and they said something like "its only a million integers, its incredibly fast, don't worry about it". Turns out they're absolutely right. The performance impact is nearly negligible to my program's performance.
So to break down my lack of understanding:
- I cannot translate lines of code into CPU cycles, because I'm writing Java
- Say I knew the cycle count for the JVM, I don't know how this translates into real cycle count on the underlying CPU.
- Say I knew the real cycle count, I don't understand what that would actually mean since I'm in a multitasking OS
Can anybody offer some insight? I don't need hugely detailed explanations. Ultimately I only need to understand basic performance (eg. can I loop over 1 million integers and not slow down the program?).
Last edited:
