示例#1
0
文件: base.php 项目: badlamer/hhvm
 function RunStep($runner)
 {
     BenchmarkSuite::ResetRNG();
     $this->results = array();
     $this->runner = $runner;
     $length = count($this->benchmarks);
     $index = 0;
     $suite = $this;
     $data = null;
     $RunNextSetup = null;
     $RunNextBenchmark = null;
     $RunNextTearDown = null;
     // Run the setup, the actual benchmark, and the tear down in three
     // separate steps to allow the framework to yield between any of the
     // steps.
     $RunNextSetup = function () use($suite, &$index, $length, &$RunNextBenchmark) {
         if ($index < $length) {
             try {
                 $setup = $suite->benchmarks[$index]->Setup;
                 $setup();
             } catch (Exception $e) {
                 $suite->NotifyError($e);
                 return null;
             }
             return $RunNextBenchmark;
         }
         $suite->NotifyResult();
         return null;
     };
     $RunNextBenchmark = function () use($suite, &$index, &$data, &$RunNextTearDown, &$RunNextBenchmark) {
         try {
             $data = $suite->RunSingleBenchmark($suite->benchmarks[$index], $data);
         } catch (Exception $e) {
             $suite->NotifyError($e);
             return null;
         }
         // If data is null, we're done with this benchmark.
         return is_null($data) ? $RunNextTearDown : $RunNextBenchmark();
     };
     $RunNextTearDown = function () use($suite, &$index, &$RunNextSetup) {
         try {
             $tearDown = $suite->benchmarks[$index++]->TearDown;
             $tearDown();
         } catch (Exception $e) {
             $suite->NotifyError($e);
             return null;
         }
         return $RunNextSetup;
     };
     // Start out running the setup.
     return $RunNextSetup();
 }
示例#2
0
文件: run.php 项目: jeremyadoux/hhvm
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Ported to PHP from Google's Octane v2.0 benchmarking suite for JavaScript.
include 'base.php';
include 'huffman.php';
include 'richards.php';
include 'deltablue.php';
include 'splay.php';
include 'quick-hull.php';
$success = true;
$PrintResult = function ($name, $result) {
    print "{$name}: {$result}\n";
};
$PrintError = function ($name, $error) {
    global $success, $PrintResult;
    $PrintResult($name, $error);
    $success = false;
};
$PrintScore = function ($score) {
    global $success;
    if ($success) {
        print "----\n";
        print 'Score (version ' . BenchmarkSuite::$version . "): {$score}\n";
    }
};
BenchmarkSuite::$config['doWarmup'] = null;
BenchmarkSuite::$config['doDeterministic'] = null;
BenchmarkSuite::RunSuites(array('NotifyResult' => $PrintResult, 'NotifyError' => $PrintError, 'NotifyScore' => $PrintScore));