Getting a cachegrind/flamegraph would be ideal. There most likely is some code that can be optimized in there.
There's any way I could improve performance?
Most likely yes. If you can wrap the call to the expensive code in a cache call that can be a quick fix. If the data changes quite regularly, and you're ok with data that is a couple of minutes old, you can use HTTPRL's function cache (httprl_call_user_func_array_cache). We use it for some crazy expensive things that take 10 minutes to calculate (stats on every user of our site). The nice thing is it has cache_lifetime_min and cache_lifetime_max; cache_lifetime_min is how long to wait until new data is generated and cache_lifetime_max is how old of data do you want to use. It uses "threading" to make the cache generation part non blocking. Example code below. The first 2 parameters are the same as call_user_func_array(), the last parameter is an array and it controls how the function cache works.
// Don't regenerate until data is 2 minutes old.
// Use data up to 1 day old.
// Function is slow give it 1 minute to run.
// Return NULL if there is no cache data. If FALSE and the cached data doesn't exist, the function will block.
// Store cached data in the cache_custom table/bin. This table needs to exist, or choose to not set it and it defaults to the cache bin.
return httprl_call_user_func_array_cache('function_name', array($uid), array(
'cache_lifetime_min' => 120,
'cache_lifetime_max' => 86400,
'lock_timeout' => 60,
'return_null_cache_miss' => TRUE,
'bin' => 'cache_custom',