Physikerwelt has submitted this change and it was merged. Change subject: Measure performance ......................................................................
Measure performance UpdateMath.php measures performance of individual math rendering steps (for LaTeXML) now. Change-Id: I872cab0bdf9c8b6a42b3ddb33d791a5ea19f8745 --- M MathSearch.hooks.php A db/mathperformance.sql M maintenance/UpdateMath.php 3 files changed, 51 insertions(+), 8 deletions(-) Approvals: Physikerwelt: Verified; Looks good to me, approved diff --git a/MathSearch.hooks.php b/MathSearch.hooks.php index e56501a..fd2f3a1 100644 --- a/MathSearch.hooks.php +++ b/MathSearch.hooks.php @@ -34,6 +34,7 @@ $updater->addExtensionTable( 'mathvarstat', $dir . 'mathvarstat.sql' ); $updater->addExtensionTable( 'mathpagestat', $dir . 'mathpagestat.sql' ); $updater->addExtensionTable( 'mathsemantics', $dir . 'mathsemantics.sql' ); + $updater->addExtensionTable( 'mathperformance', $dir . 'mathperformance.sql' ); } else { //throw new MWException( "Math extension does not currently support $type database." ); } diff --git a/db/mathperformance.sql b/db/mathperformance.sql new file mode 100644 index 0000000..57262c4 --- /dev/null +++ b/db/mathperformance.sql @@ -0,0 +1,6 @@ +CREATE TABLE `wiki`.`mathperformance` ( + `math_inputhash` VARBINARY(16) NOT NULL, + `mathperformance_name` CHAR(10) NOT NULL, + `mathperformance_time` DOUBLE NOT NULL, + `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + INDEX `PK` (`math_inputhash` ASC, `mathperformance_name` ASC)); \ No newline at end of file diff --git a/maintenance/UpdateMath.php b/maintenance/UpdateMath.php index bfb2c61..b7e4103 100644 --- a/maintenance/UpdateMath.php +++ b/maintenance/UpdateMath.php @@ -24,7 +24,12 @@ class UpdateMath extends Maintenance { const RTI_CHUNK_SIZE = 100; var $purge = false; + /** @var boolean */ + private $verbose; + /** @var DatabaseBase */ var $dbw = null; + /** @var MathRenderer */ + private $current; private $time = 0;//microtime( true ); private $performance = array(); @@ -36,19 +41,31 @@ * */ public function __construct() { + $this->verbose = $this->verbose; parent::__construct(); $this->mDescription = 'Outputs page text to stdout'; - $this->addOption( 'purge', "If set all formulae are rendered again from strech. (Very time consuming!)", false, false, "f" ); + $this->addOption( 'purge', "If set all formulae are rendered again without using caches. (Very time consuming!)", false, false, "f" ); $this->addArg( 'min', "If set processing is started at the page with rank(pageID)>min", false ); $this->addArg( 'max', "If set processing is stopped at the page with rank(pageID)<=max", false ); + $this->addOption( 'verbose', "If set output for successful rendering will produced",false,false,'v' ); } private function time($category='default'){ + global $wgMathDebug; $delta = (microtime(true) - $this->time)*1000; if (isset ($this->performance[$category] )) $this->performance[$category] += $delta; else $this->performance[$category] = $delta; + if($wgMathDebug){ + $this->db->insert('mathperformance',array( + 'math_inputhash' => $this->current->getInputHash(), + 'mathperformance_name' => substr($category,0,10), + 'mathperformance_time' =>$delta, + )); + + } $this->time = microtime(true); + return (int) $delta; } /** @@ -103,22 +120,36 @@ */ private function doUpdate( $pid, $pText, $pTitle = "") { // TODO: fix link id problem + $notused = null; $anchorID = 0; - $res = ""; $pText = Sanitizer::removeHTMLcomments( $pText ); + $pText = preg_replace( '#<nowiki>(.*)</nowiki>#', '', $pText ); $matches = preg_match_all( "#<math>(.*?)</math>#s", $pText, $math ); if ( $matches ) { echo( "\t processing $matches math fields for {$pTitle} page\n" ); foreach ( $math[1] as $formula ) { - $this->time("initilize"); + $this->time = microtime(true); $renderer = MathRenderer::getRenderer( $formula, array(), MW_MATH_LATEXML ); - $this->time("load renderer"); + $this->current = $renderer; + $this->time("loadClass"); if ( $renderer->checkTex() ){ - $this->time("check tex"); + $this->time("checkTex"); $renderer->render( $this->purge ); - $this->time("rendering"); + if( $renderer->getMathml() ){ + $this->time("LaTeXML-Rendering"); + } else { + $this->time("LaTeXML-Fail"); + } + $svg = $renderer->getSvg(); + if( $svg ){ + $this->time("SVG-Rendering"); + } else { + $this->time("SVG-Fail"); + } + }else{ - echo "texvcheck error:" . $renderer->getLastError(); + $this->time("checkTex-Fail"); + echo "\nF:\t\t".$renderer->getMd5()." texvccheck error:" . $renderer->getLastError(); continue; } wfRunHooks( 'MathFormulaRendered', array( &$renderer , &$notused, $pid, $anchorID ) ); @@ -127,9 +158,13 @@ $this->time("write Cache"); if ( $renderer->getLastError() ) { echo "\n\t\t". $renderer->getLastError() ; - echo "\nF:\t\t equation " . ( $anchorID -1 ) . + echo "\nF:\t\t".$renderer->getMd5()." equation " . ( $anchorID -1 ) . "-failed beginning with\n\t\t'" . substr( $formula, 0, 100 ) . "'\n\t\tmathml:" . substr($renderer->getMathml(),0,10) ."\n "; + } else{ + if($this->verbose){ + echo "\nS:\t\t".$renderer->getMd5(); + } } } return $matches; @@ -143,6 +178,7 @@ global $wgMathValidModes; $this->dbw = wfGetDB( DB_MASTER ); $this->purge = $this->getOption( "purge", false ); + $this->verbose = $this->getOption("verbose",false); $this->db = wfGetDB( DB_MASTER ); $wgMathValidModes[] = MW_MATH_LATEXML; $this->output( "Loaded.\n" ); -- To view, visit https://gerrit.wikimedia.org/r/116453 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I872cab0bdf9c8b6a42b3ddb33d791a5ea19f8745 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/MathSearch Gerrit-Branch: master Gerrit-Owner: Physikerwelt <w...@physikerwelt.de> Gerrit-Reviewer: Physikerwelt <w...@physikerwelt.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits