wins1ey / LibreSplit

Free speedrun timer with auto splitting and load removal for Linux.
GNU General Public License v3.0
21 stars 7 forks source link

Use fopen instead of a shell command to get memory maps #18

Closed EXtremeExploit closed 7 months ago

EXtremeExploit commented 7 months ago

This optimizes the function find_base_address to open the file maps file and searching for the map directly instead of spawning a child shell that executes the command and gathers its output. It used to take around 10 whole milliseconds for a single readAddress, now its around 1 millisecond. Allowing 240Hz refresh rate if there are less than 4 readAddresses (240Hz requires the loop to take less than 1000/240 which equals to around 4.166ms) in each auto-splitter loop. Also if you had 2 readAddress or more, it would never run at 60Hz because it was taking at least 20ms, so it was more like 45-50ish

TLDR: readAddress now takes 1ms instead of 10ms, which is a 10x improvement

Loomeh commented 7 months ago

Was initially going to merge because everything seemed fine but I noticed that LAST crashes with a segmentation fault when the attached program suddenly closes (at least in the case of Jet Set Radio).

EXtremeExploit commented 7 months ago

Added a safeguard to when the file fails to open, the segfault should be fixed now

Loomeh commented 7 months ago

Thank you, LAST no longer seems to be segfaulting. Will merge now.