0xDEADBEEF

RSS odkazy

iotest.php

6. 1. 2021 #kód
const PAGE = 1 << 12;

$fileName = 'really-big-file.bin';
$readSize = PAGE;

$f = fopen($fileName, 'r');
stream_set_chunk_size($f, $readSize);

$size = filesize($fileName);
$times = [];

for ($i = 0; $i < 200; $i++) {
  $off = mt_rand(0, $size) & ~(PAGE-1);

  $s = hrtime(true);
  fseek($f, $off);
  fread($f, $readSize);
  $times[$i] = hrtime(true)-$s;
}

sort($times);

foreach ($times as $t) {
  echo $t, " ns\n";
}
píše k47 (@kaja47, k47)