Have you been through the settings>device care menu? There are some optimisation options in there that’ll show you any apps which have high battery consumption for example.
Settings> Device Care > Optimise Now clears a load of rubbish that can slow things down.
Settings> Device Care > Memory > Memory Resident Apps will show you any apps which keep themselves alive in the RAM. You can disable them if there anything random in there.
Settings> Device Care > Memory > RAM Plus Allows to to increase virtual memory.
I just downloaded an app called ‘Resource Monitor Mini’ which gives you an overlay on the screen showing CPU and. Memory usage in real time. Might be useful? Doesn’t look like it records anything but it’ll show you if you’re maxied out in the CPU or Memory when your phone locks up.