Outils pour utilisateurs

Outils du site


informatique:php:shared_memory:essais02

Ceci est une ancienne révision du document !


<!DOCTYPE HTML PUBLIC “-W3CDTD HTML 4.01 TransitionalEN”> Shared Memory - Essais02

Shared Memory - Essais02

'; $SHM_KEY = getShmKey(); $size = 1024*1024 ; for( $i=0; $i<60; $i++) { $size=intval($size); if( $size==0 ) break; $data = shm_attach( $SHM_KEY, $size, 0600); if( $data == null || $data === FALSE) { echo 'FAILED for size='.formatBytesSize($size)."\n"; break; } else { echo 'OK for size='.formatBytesSize($size)."\n"; shm_remove($data); shm_detach($data); } $size += 1024*1024 ; } echo ''; } /** * @parame int $sizeInBytes * @return string */ function formatBytesSize( $sizeInBytes, $afterColon=2) { // less than 1kB if($sizeInBytes < 1024) { return $sizeInBytes . ' B'; } // between 1kB and 1MB if ($sizeInBytes >= 1024 && $sizeInBytes < 1048576) { return number_format( $sizeInBytes / 1024, $afterColon) . ' KB'; } // between 1MB and 1GB if ($sizeInBytes >= 1048576 && $sizeInBytes < 1073741824) { return number_format( $sizeInBytes / 1048576, $afterColon) . ' MB'; } // more than 1GB return number_format( $sizeInBytes / 1073741824, $afterColon) . ' GB'; } ?>

informatique/php/shared_memory/essais02.1267464781.txt.gz · Dernière modification : 19/05/2012 00:15 (modification externe)

Sauf mention contraire, le contenu de ce wiki est placé sous les termes de la licence suivante : CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki