6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed Jun 05, 2024 10:50 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Counting cycles
PostPosted: Thu Aug 05, 2021 12:26 am 
Offline

Joined: Tue Feb 24, 2015 11:07 pm
Posts: 81
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Counting cycles
PostPosted: Thu Aug 05, 2021 12:57 am 
Offline

Joined: Fri Apr 15, 2016 1:03 am
Posts: 136
One option is to set up & run some test cases in a simulator that counts execution cycles.
For example: the Kowalski assembler & simulator: http://forum.6502.org/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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Counting cycles
PostPosted: Thu Aug 05, 2021 1:04 am 
Offline
User avatar

Joined: Mon Apr 23, 2012 12:28 am
Posts: 760
Location: Huntsville, AL
The approach that I use for counting cycles is to use the py65 simulator. It has a cycle counter function built-in.

_________________
Michael A.


Top
 Profile  
Reply with quote  
 Post subject: Re: Counting cycles
PostPosted: Thu Aug 05, 2021 7:25 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10822
Location: England
And there was me about to suggest visual6502...


Top
 Profile  
Reply with quote  
 Post subject: Re: Counting cycles
PostPosted: Thu Aug 05, 2021 12:04 pm 
Offline
User avatar

Joined: Sun Nov 01, 2020 10:36 am
Posts: 35
Location: Tatooine
Some emulators do that. Vice for example.


Attachments:
ViceCycleCount.jpg
ViceCycleCount.jpg [ 150.99 KiB | Viewed 799 times ]
Top
 Profile  
Reply with quote  
 Post subject: Re: Counting cycles
PostPosted: Fri Aug 06, 2021 3:52 am 
Offline

Joined: Wed Oct 07, 2020 6:43 pm
Posts: 6
sim65 from cc65 package will count cycles when started with -c or --cycles.


Top
 Profile  
Reply with quote  
 Post subject: Re: Counting cycles
PostPosted: Fri Aug 06, 2021 11:41 pm 
Offline

Joined: Sun Apr 26, 2020 3:08 am
Posts: 357
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Counting cycles
PostPosted: Sun Aug 08, 2021 9:23 am 
Offline

Joined: Tue Feb 24, 2015 11:07 pm
Posts: 81
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/?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: