Counting cycles
Counting cycles
What tools are available for counting cycles? I'm interested in comparing the performance of different implementations of a subroutine, but I don't want to count cycles by hand because I'm likely to make a mistake.
-
leepivonka
- Posts: 168
- Joined: 15 Apr 2016
Re: Counting cycles
One option is to set up & run some test cases in a simulator that counts execution cycles.
For example: the Kowalski assembler & simulator: viewtopic.php?f=8&t=5011
A related option is to set up & run some test cases on real hardware with a timer.
Another option is to do static analysis on your subroutine. I assume this is what you were thinking of as complex & error-prone.
You would look up & sum the cycles required for each case of each instruction on the various execution paths through your subroutine.
For example: the Kowalski assembler & simulator: viewtopic.php?f=8&t=5011
A related option is to set up & run some test cases on real hardware with a timer.
Another option is to do static analysis on your subroutine. I assume this is what you were thinking of as complex & error-prone.
You would look up & sum the cycles required for each case of each instruction on the various execution paths through your subroutine.
Re: Counting cycles
The approach that I use for counting cycles is to use the py65 simulator. It has a cycle counter function built-in.
Michael A.
Re: Counting cycles
And there was me about to suggest visual6502...
Re: Counting cycles
sim65 from cc65 package will count cycles when started with -c or --cycles.
Re: Counting cycles
If the accuracy of cycle counting is not needed, then just call your subroutine then a speaker toggle switch, one after the other and in a loop, multiple times. The speaker will toggle faster for a fast subroutine and make a higher pitch.
Re: Counting cycles
Thank you all for the suggestions. I love the speaker idea for comparing relative performance. I already had cc65 but didn't realize that sim65 was there. Is the sim65 in cc65 related at all to the sim65 at http://www.wsxyz.net/sim65/?