note 79161 added to function.md5-file

From: Date: Wed, 14 Nov 2007 01:54:11 +0000
Subject: note 79161 added to function.md5-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-132246@lists.php.net to get a copy of this message
It's much faster to call an 'exec' command to openssl md5 than to use md5_file. <?php $file_path = '/path/to/large/video_file.mov'; $begin = microtime(true); $hash = md5_file($file_path); $end = microtime(true) - $begin; echo "Hash = $hash; time = $end<br>"; # Hash = eac425a6f5b90f69e74710b015228640; time = 2.5333859920502 $begin = microtime(true); $result = split('=',exec("openssl md5 $file_path")); $end = microtime(true) - $begin; echo "Hash = ".$result[1]."; time = $end"; #Hash = eac425a6f5b90f69e74710b015228640; time = 0.79528999328613 ?> I consistently see about a 3x improvement in speed. ---- Server IP: 64.71.164.2 Probable Submitter: 66.92.37.171 ---- Manual Page -- http://www.php.net/manual/en/function.md5-file.php Edit -- https://master.php.net/note/edit/79161 Del: integrated -- https://master.php.net/note/delete/79161/integrated Del: useless -- https://master.php.net/note/delete/79161/useless Del: bad code -- https://master.php.net/note/delete/79161/bad+code Del: spam -- https://master.php.net/note/delete/79161/spam Del: non-english -- https://master.php.net/note/delete/79161/non-english Del: in docs -- https://master.php.net/note/delete/79161/in+docs Del: other reasons-- https://master.php.net/note/delete/79161 Reject -- https://master.php.net/note/reject/79161 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132246) next »