In case you're interested (having Python, Ruby, ... around I thought
  you might be :-), here's a PHP version of the MOPS test.

#!/usr/bin/php
<?php
#
# mops.php
#
# A PHP implementation of the mops.pasm example program,
# for speed comparisons.
#
# Copyright (C) 2001 The Parrot Team. All rights reserved.
# This program is free software. It is subject to the same
# license as The Parrot Interpreter.
#
# $Id: $
#

set_time_limit(0);

$i2 = 0;                     # set    I2, 0
$i3 = 1;                     # set    I3, 1
$i4 = 100000000;             # set    I4, 100000000
                             #
print "Iterations:    $i4\n";# print  "Iterations:    "
                             # print  I4
                             # print  "\n"
                             #
$i1 = 2;                     # set    I1, 2
$i5 = $i4 * $i1;             # mul    I5, I4, I1
                             #
print "Estimated ops: $i5\n";# print  "Estimated ops: "
                             # print  I5
                             # print  "\n"
                             #
$n1 = time();                # time N1
                             #
while ($i4 != 0)             # REDO:
  $i4 = $i4 - $i3;           # sub    I4, I4, I3
                             # if     I4, REDO
                             #
                             # DONE:
$n5 = time();                # time   N5
                             #
$n2 = $n5 - $n1;             # sub    N2, N5, N1
                             #
print "Elapsed time:  $n2\n";# print  "Elapsed time:  "
                             # print  N2
                             # print  "\n"
                             #
$n1 = $i5;                   # iton   N1, I5
$n1 = $n1 / $n2;             # div    N1, N1, N2
$n2 = 1000000.0;             # set    N2, 1000000.0
$n1 = $n1 / $n2;             # div    N1, N1, N2
                             #
print "M op/s:        $n1\n";# print  "M op/s:        "
                             # print  N1
                             # print  "\n"
                             #
                             # end
?>

-- 
  Sebastian Bergmann
  http://sebastian-bergmann.de/                 http://phpOpenTracker.de/

  Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/

Reply via email to