Physikerwelt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/258126

Change subject: Add fault tolerance to tests
......................................................................

Add fault tolerance to tests

Change-Id: Id50963f616c8181e6ef93e2c3c9f018de4b9a310
---
M maintenance/MathPerformance.php
A maintenance/performance.sh
2 files changed, 33 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch 
refs/changes/26/258126/1

diff --git a/maintenance/MathPerformance.php b/maintenance/MathPerformance.php
index eb5681b..b5022ae 100644
--- a/maintenance/MathPerformance.php
+++ b/maintenance/MathPerformance.php
@@ -67,7 +67,8 @@
                                $this->actionBenchmark();
                                break;
                }
-               $this->vPrint( "Done." );
+               $shareString = $this->getArg( 2, '' );
+               $this->vPrint( "{$shareString}Done." );
        }
 
        private function actionExport() {
@@ -125,19 +126,14 @@
                foreach ( $formulae as $formula ) {
                        $this->currentHash = $formula->$hash;
                        $rbi = new MathRestbaseInterface( $formula->$tex, false 
);
-                       $this->resetTimer();
-                       $rbi->checkTeX();
-                       $this->time( 'check' );
-                       if ( round( rand( 0, 1 ) ) ) {
-                               $rbi->getSvg();
-                               $this->time( '1-svg' );
-                               $rbi->getMathML();
-                               $this->time( '2-mathml' );
-                       } else {
-                               $rbi->getMathML();
-                               $this->time( '1-mathml' );
-                               $rbi->getSvg();
-                               $this->time( '2-svg' );
+                       if ( $this->runTest( $rbi ) ) {
+                               if ( round( rand( 0, 1 ) ) ) {
+                                       $this->runTest( $rbi, 'getSvg', '1-' ) 
&&
+                                       $this->runTest( $rbi, 'getMathML', '2-' 
);
+                               } else {
+                                       $this->runTest( $rbi, 'getMathML', '1-' 
) &&
+                                       $this->runTest( $rbi, 'getSvg', '2-' );
+                               }
                        }
                }
        }
@@ -182,6 +178,20 @@
                        $this->output( $string . "\n" );
                }
        }
+
+       private function runTest( MathRestbaseInterface $rbi, $method = 
'checkTeX', $prefix = '' ) {
+               try{
+                       $this->resetTimer();
+                       call_user_func( array( $rbi, $method ) );
+                       $this->time( $prefix . $method );
+                       return true;
+               } catch( Exception $e ){
+                       $this->vPrint( "Tex:{$rbi->getTex()}" );
+                       $this->vPrint( $e->getMessage() );
+                       $this->vPrint( $e->getTraceAsString() );
+                       return false;
+               }
+       }
 }
 
 $maintClass = "MathPerformance";
diff --git a/maintenance/performance.sh b/maintenance/performance.sh
new file mode 100644
index 0000000..cd9ee1c
--- /dev/null
+++ b/maintenance/performance.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+START=0
+END=1 #$(nproc)
+for ((i=START; i<END; i++))
+do
+   echo "Starting process: $i"
+   # php ./MathPerformance.php benchmark $END $i --table=statistics 
--input=tex --hash=hash -v > log"$i".out &
+   php ./MathPerformance.php benchmark $END $i &
+done
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/258126
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id50963f616c8181e6ef93e2c3c9f018de4b9a310
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to