Closed mithrendal closed 6 months ago
The best way to solve it cleanly is probably to replace the macros with inline functions overloaded for different types.
The best way to solve it cleanly is probably to replace the macros with inline functions overloaded for different types.
Despite being the clearest solution, it is apparently not the best. The compiler does not optimize away the function call in debug builds, even for trivial functions:
Using (overloaded) functions would thus slow down the emulator in debug mode, which I don't want to happen.
I went for this solution for now:
#define USEC(delay) (Cycle((i64)delay * 28))
#define MSEC(delay) (Cycle((i64)delay * 28000))
#define SEC(delay) (Cycle((double)delay * 28000000))
https://github.com/dirkwhoffmann/vAmiga/blob/6d5f076e747c2d1860001d3808cc72e5ed500022/Emulator/Base/Aliases.h#L46
with the latest commit 6d5f076e747c2d1860001d3808cc72e5ed500022 the SEC(number_in_seconds) macro above cuts the fractional part of the number. It therefore translates to
SEC(0.5) == SEC(0)
and
SEC(1.8) == SEC(1)
when agnus schedules tasks for example every SEC(0.5) then it runs these tasks now in every slot ... which leads to higher host cpu load.
solution
use MSEC(500) instead of SEC(0.5) use MSEC(1800) instead of SEC(1.8)