ありがとう@Phihag、あなたの情報はfseek
と一緒にftell
私ははるかに良い方法でサイズを計算することができます。ここにコードを見てください:http://pastebin.com/7XCqu0WR
<?php
$fp = fopen("/tmp/temp.rock", "a+");
fwrite($fp, "This is the contents");
echo "Time taken to calculate the size by filesize function: ";
$t = microtime(true);
$ts1 = filesize("/tmp/temp.rock") . "\n";
echo microtime(true) - $t . "\n";
echo "Time taken to calculate the size by fstat function:";
$t = microtime(true);
$ts1 = fstat($fp) . "\n";
$size = $ts1["size"];
echo microtime(true) - $t . "\n";
echo "Time taken to calculate the size by fseek and ftell function: ";
$t = microtime(true);
fseek($fp, 0, SEEK_END);
$ts2 = ftell($fp) . "\n";
echo microtime(true) - $t . "\n";
fclose($fp);
/**
OUTPUT:
Time taken to calculate the size by filesize function:2.4080276489258E-5
Time taken to calculate the size by fstat function:2.9802322387695E-5
Time taken to calculate the size by fseek and ftell function:1.2874603271484E-5
*/
?>
ありがとう、 'fseek'の情報がトリックでした。私は 'ftell'と一緒に' fseek'を使いました。そして、それは最も速かったです。 –