Created
November 9, 2010 07:19
Revisions
-
supernifty revised this gist
Nov 9, 2010 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ <?php $profile = true; require_once "profile.php"; profile_start(); // ... $query = mysql_queryx( "select status from table" ); // ... profile_info( "checkpoint" ); // ... profile_end( "page" ); ?> -
supernifty created this gist
Nov 9, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ <?php $_start = 0; $_subdata = ''; function profile_start() { global $profile; if ( $profile ) { global $_start, $_subdata; $_start = microtime(true); $_subdata = ''; } } function profile_end( $data ) { global $profile, $_subdata; if ( $profile ) { global $_start; // open file $fd = fopen("/tmp/profile.csv", "a"); // write string fwrite($fd, ( microtime(true) - $_start ) . "," . $data . "\n"); fwrite($fd, $_subdata ); // close file fclose($fd); } } function profile_info( $q ) { global $profile, $_subdata, $_start; if ( $profile ) { $_subdata .= (microtime(true) - $_start) . ",\"- " . $q . "\"\n"; } } function mysql_queryx( $q ) { global $profile, $_subdata; if ( $profile ) { $pre = microtime(true); $result = mysql_query( $q ); $_subdata .= (microtime(true) - $pre) . ",\"- " . $q . "\"\n"; return $result; } else { return mysql_query( $q ); } } ?> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ <?php $profile = true; require_once ‘profile.php’; profile_start(); … $query = mysql_queryx( “select status from table” ); … profile_info( “checkpoint” ); … profile_end( “page” ); ?>