Page 1 of 1

C/ASM profiling tools?

Posted: Tue Oct 30, 2018 12:43 am
by NekoNoNiaow
Hello kittens!

Does anyone know which profiling tools are available for Oric programs aside from the reliable but quite basic OSDK clock() function?
A cursory search in the forums and well as on the web did not reveal anything and it does not look like the OSDK C/ASM compiler/assembler support some kind of profiling output.

I guess some emulators which are able to load debug symbols might also offer that kind of tools but there as well I was not able to find anything.

Note that my needs are quite rudimentary at the moment and satisfied by the clock() function but I am naturally curious. ;)

Re: C/ASM profiling tools?

Posted: Tue Oct 30, 2018 7:58 am
by Dbug
It's my profiler:
http://miniserve.defence-force.org/svn/ ... /Profiler/

Maybe I should make it easy to add to OSDK projects and document how to use it...

Regarding emulators, Oricutron has an internal cycle counter that you can reset:
http://www.osdk.org/index.php?page=docu ... =oricutron

So just set it to zero, step in your routine, look at the value when exiting.

Re: C/ASM profiling tools?

Posted: Tue Oct 30, 2018 9:01 am
by iss
Just small addition for Oricutron's internal cycle counter - you can control it with breakpoints too.
For more info see my post here and the ReadMe.txt.

Re: C/ASM profiling tools?

Posted: Tue Oct 30, 2018 2:41 pm
by Chema
It is a pity that nobody jumped into the expansion I proposed to Oricutron. My idea was adding support for external tools, at least, receive commands and send data back to an external application (using a socket or any other method). I suggested this to the author of a spectrum emulator and the results were incredible.

You can send all the debugger commands but also you inspect/modify memory in real time, or do profiling by getting the cycles used from one point to another as many time as you wish in a full run and run statistics over the results... even in real time.

That sort of things that would be invaluable for programmers like me :)

Re: C/ASM profiling tools?

Posted: Wed Oct 31, 2018 2:47 am
by NekoNoNiaow
Dbug wrote:
Tue Oct 30, 2018 7:58 am
It's my profiler:
http://miniserve.defence-force.org/svn/ ... /Profiler/
Maybe I should make it easy to add to OSDK projects and document how to use it...
Thanks! For a start this is indeed useful and yup, this looks like this would belong as a part of the OSDK library.

Obviously, it would be even better if we could have scope-profiling by simply defining profiling class instances but this would require a c++ compiler and I guess we are not there yet. ;)

For those who are curious, this would look like this:

Code: Select all

void my_function(int a, int b)
{
   PROFILE(my_function);  // <- a macro, actually translates to -> ScopeProfiler profiler_L122_my_function("my_function")
   
   while ( whatever)
   {
   	PROFILE(loop);		// translates to -> ScopeProfiler profiler_L126_loop("loop")
   	// ...
   }
}
Chema wrote:
Tue Oct 30, 2018 2:41 pm
It is a pity that nobody jumped into the expansion I proposed to Oricutron. My idea was adding support for external tools, at least, receive commands and send data back to an external application (using a socket or any other method). I suggested this to the author of a spectrum emulator and the results were incredible.
Actually, DBug did and suggested a GDB extension for Oricutron, which is kinda the generalization of your suggestion, and which I find absolutely great.
The advantage of the GDB standard is that it is supported by many IDEs (Visual Studio for example), so this would allow to debug Oric applications from our preferred IDE.

Maybe we should create an official issue/request on the GitHub page and vote it up? ;)
iss wrote:
Tue Oct 30, 2018 9:01 am
Just small addition for Oricutron's internal cycle counter - you can control it with breakpoints too.
For more info see my post here and the ReadMe.txt.
I see, thanks!

Re: C/ASM profiling tools?

Posted: Sun Nov 11, 2018 5:33 pm
by Dbug
Since the topic has gotten some attention, I decided to spend a bit of time writing a blog post about it:
http://osdk.org/index.php?page=articles&ref=ART11

If you are interested, the code of the "racing game" prototype with the integrated profiler is on the SVN depot:
http://miniserve.defence-force.org/svn/ ... ames/Road/

Re: C/ASM profiling tools?

Posted: Sun Nov 11, 2018 9:17 pm
by iss
Very interesting information. I have to try the example (on multi CPU platform :lol:)!

Re: C/ASM profiling tools?

Posted: Fri Nov 16, 2018 12:37 am
by NekoNoNiaow
Great article!
Thanks for putting in the effort.

I will be using these routines/macros veryyyyy soon. ;)

Re: C/ASM profiling tools?

Posted: Fri Nov 16, 2018 8:42 pm
by Dbug
I've posted a follow up article on the same topic, with some concrete example of how to optimize code:
http://www.osdk.org/index.php?page=articles&ref=ART12

Re: C/ASM profiling tools?

Posted: Tue Nov 27, 2018 2:01 am
by NekoNoNiaow
Dbug wrote:
Fri Nov 16, 2018 8:42 pm
I've posted a follow up article on the same topic, with some concrete example of how to optimize code:
http://www.osdk.org/index.php?page=articles&ref=ART12
Very nice article by the way!
It gave me a few ideas for further optimizations of that vertical scroll routine but I must concentrate on my stuff now or I will never advance. ;)