My solution is based on this answer.
Every view of mine has a footer.phtml attached to it, so if I print it there, there will be no need to change many files.
To print the time there, first I wrote something specific to that footer.phtml, for example Execution time:
Than in module/Application/Module.php
I added this code to onBootstrap()
$eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_FINISH, function($e) {
$time = microtime(true) - REQUEST_MICROTIME;
// formatting time to be more friendly
if ($time <= 60) {
$timeF = number_format($time, 2, ',', '.').'s'; // conversion to seconds
} else {
$resto = fmod($time, 60);
$minuto = number_format($time / 60, 0);
$timeF = sprintf('%dm%02ds', $minuto, $resto); // conversion to minutes and seconds
}
// Search static content and replace for execution time
$response = $e->getResponse();
$response->setContent(str_replace(
'Execution time:', 'Execution time: '.$timeF, $response->getContent()));
}, 100000);