Mendix has some tooling to do this: https://docs.mendix.com/addons/apd-addon/#1-introduction
Note though that there are costs involved when using this tool.
Mendix is also working on Mendix assist to help you find performance mistakes but that is for the future.
There are some good blog posts about performance. Start with this one: https://blog.mansystems.com/how-to-speed-up-your-mendix-app-part-1