Optimize Logic Hooks and API Response Time

We are currently using Sugar Enterprise 14.0 onsite and have implemented custom logic hooks and API endpoints to handle some of our complex business processes. However, we are experiencing performance issue with response times of these customizations and are seeking your assistance to optimize them.
Issue Faced: -
The response times for both the logic hooks and API calls are longer than expected.
There is noticeable delay which impacts the user experience and overall system performance.
Request for Assistance: -
Could you provide best practices for writing efficient logic hooks and in API (like load relationship function or else)?
Are there any inbuilt functions or methods in SugarCRM that can help optimize database queries or API responses?
Any recommendation on caching mechanism or other techniques to reduce response time?
Are there any tools or built-in features in SugarCRM for profiling and optimizing custom code?
If possible, please provide example code snippets or reference implementations that demonstrate efficient use of logic hooks and custom API endpoints.
Thank you for your support and looking forward to your response.