This really isn't an answer but an explanation:
passing-by-reference to a function offers much worse performance than passing-by-value
This may be but it's not really the purpose of pass by reference. The purpose is to update the original without returning data or making a copy of the data.
So to test this
$greetings = function () use (&$message) {
echo $message;
};
VS
$greetings = function () use ($message) {
echo $message;
};
Is not really fair as the first one is doing things the second one is not. And there is no purpose (or point) to use Pass by Reference there.
A fair test would be this:
$message = "foo";
$greetings = function () use (&$message) {
$message .= " bar";
};
$greetings();
//$message = "foo bar";
VS
$message = "foo";
$greetings = function() use ($message){
return $message . " bar";
};
$message = $greetings();
//$message = "foo bar";
So to test just calling it without testing how it affects the data, doesn't do it justice. In other words, the first pair of examples maybe Pass-by reference is slower. But in the second pair is that still true, how about memory usage etc.
In any case you can time them like this:
$start = microtime(true);
//...some code to test
echo format_number((microtime(true) - $start), 2));
But you may have to do it in a loop to make it take enough time to measure. And even then, it will depend in large part on what the data is you are passing.