ob_get_clean()
will return a string. To obtain the number of bytes write
$sebesseg = ob_get_clean();
$numberOfBytes = strlen($sebesseg);
After reading your last comment, I've preapred a short example how a simple download speed measurement script can be done with PHP. The following code should do what you want:
<?php
// get the start time as UNIX timestamp (in millis, as float)
$tstart = microtime(TRUE);
// start outout buffering
ob_start();
// display your page
include 'some-page.php';
// get the number of bytes in buffer
$bytesWritten = ob_get_length();
// flush the buffer
ob_end_flush();
// how long did the output take?
$time = microtime(TRUE) - $tstart;
// convert to bytes per second
$bytesPerSecond = $bytesWritten / $time;
// print the download speed
printf('<br/>You\'ve downloaded %s in %s seconds',
humanReadable($bytesWritten), $time);
printf('<br/>Your download speed was: %s/s',
humanReadable($bytesPerSecond));
/**
* This function is from stackoverflow. I just changed the name
*
* http://stackoverflow.com/questions/2510434/php-format-bytes-to-kilobytes-megabytes-gigabytes
*/
function humanReadable($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
// Uncomment one of the following alternatives
//$bytes /= pow(1024, $pow);
$bytes /= (1 << (10 * $pow));
return round($bytes, $precision) . ' ' . $units[$pow];
}
Note that the real download speed can only measured at the client. But the results from the code above should be approximately ok.
Also it would just measure the download size of the HTML page itself. Images. styles and javascripts will extend the real download size of page load. But the speed should be in most cases the same the HTML document.