News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

[CPCTELERA] Best way to measure performance

Started by awergh, 15:04, 20 October 18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

awergh

So as I am looking for performance it is helpful to be able to measure performance.

For memory it is easy as the amount of memory used is listed during compiling.


However for CPU performance I am not as sure.
I have been using cpct_count2VSYNC but have also got some strange results with it.
Is this the best way or is there other techniques for accurately measuring performance?

cperezgrin

I learnt a simple way in a ronaldo's video.
You can use the temporizer in winape to measure microseconds.
Put two breakpoints between the process you want to measure, and run. When the first breakpoint stops the running, reset the temporizer. Close debug window, when the second breakpoint stops the program again, you have the microseconds in the temporizer field.

SpDizzy

Maybe you can try to set a breakpoint on Winape debugger at the start of your game update loop. Clear the time counter (T label under main registers, on the up right of the screen) and close debugger. It will pop up automatically on next iteration. T label now shows time passed on microseconds over the iteration. Max 66560 cycles per frame for 50 fps, that is 20 milliseconds time passed

ronaldo

Quote from: awergh on 15:04, 20 October 18
I have been using cpct_count2VSYNC but have also got some strange results with it.
Is this the best way or is there other techniques for accurately measuring performance?


Take into account that cpct_count2VSYNC is just a loop that counts the number of iterations. There is no way in which the function can return strange results. If you feel that returned results do not match what you expect, you should then trace your code. You may be having frames longer than 1/50s or variable, you may be calling count2VSYNC sometimes when VSYNC is on, or calling it 2 consecutive times before VSYNC has turned off. There are many possibilities, but they all relate to your code, because count2VSYNC is trivial and cannot produce such strange results by itself.


With respect to measuring performance it depends on what you want. For instance, all #CPCtelera functions include exact performance measures in the documentation. You can know beforehand how much they are going to cost you in microseconds and bytes. You may also measure parts of your program using WinAPE's microsecond counter, as others have already suggested you. You may also create a counter using interrupts. If your program does not mess up interrupt sequence, you have 300 per second, so you can easily measure time. You may also manually count microseconds in your algorithms by counting microseconds of each instruction.


There are many options, but there is no best way in advance. It heavily depends on your purpose.


By the way, Amstrad takes 19968 microseconds to render each frame in standard modes. That's roughly 1/50s.

awergh

Perhaps cpct_count2VSYNC doesn't work how I think it does.
I was basically trying to use it as a timer and was assuming that lower is better.


I didn't keep it but what confused me is I had a loop that counted down from 255 and it returned 14000 and when I added some other stuff (some divides and multiplies) inside the loop it returned 23 which didn't make sense to me as the former was doing significantly less than the latter.


I suspect that using WinAPE is better for my purpose as I don't have to make code changes to test it, the only downside is that I have to find where the code I want to profile is.

SpDizzy

#5
QuoteI suspect that using WinAPE is better for my purpose as I don't have to make code changes to test it, the only downside is that I have to find where the code I want to profile is.
That's an easy one. Just look for .map file on the /obj folder of your project. Let's say your project name is 'retrodev', hence look for 'retrodev.map' on that folder. There you can see where on memory resides your data and code functions. Then on Winape you can put a breakpoint on those memory directions.

On respect to count2Vsync, the bigger the better, so it counts iterations waiting for Vsync. Higher value means more time available till next Vsync.
Please refer to cpctelera's manual for a complete specification on the use and measurements of this and all available functions. This one is for count2Vsync:
https://lronaldo.github.io/cpctelera/files/video/cpct_count2VSYNC-s.html

Powered by SMFPacks Menu Editor Mod