Ämne: Performance
Visa ett inlägg
Oläst 2004-11-03, 11:31 #10
Mikael Simonsson Mikael Simonsson är inte uppkopplad
Nykomling
 
Reg.datum: Jun 2004
Inlägg: 34
Mikael Simonsson Mikael Simonsson är inte uppkopplad
Nykomling
 
Reg.datum: Jun 2004
Inlägg: 34
Ett snabbt test med ApacheBench visar att det går ungefär 3 gånger snabbare att anropa bilden direkt.

Direkt:
Citat:
./ab -n 1000 -c 10 http://localhost/dev/image.jpg
...
Requests per second: 128.14 [#/sec]
Med PHP:
Citat:
./ab -n 1000 -c 10 http://localhost/dev/image.php
...
Requests per second: 37.41 [#/sec]
Förklaring av parametrarna till ab:
Citat:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
image.php:
Kod:
$sFilename = "./image.jpg";
$f = fopen($sFilename, 'rb');

header('Content-Type: image/jpeg');
header('Content-Length: ' . filesize($sFilename));

fpassthru($f);
exit();
/ mikael
Mikael Simonsson är inte uppkopplad   Svara med citatSvara med citat