Obsolete:GCC benchmarking/Script

From Wikitech
Jump to navigation Jump to search
<?php

$olddir = getcwd();
require_once('commandLine.inc');
chdir( $olddir );

$text = file_get_contents( 'benchmark/test.txt' );
$zhtext = file_get_contents( 'benchmark/zhtest.txt' );


print "Tight loop: ";
$n = 10000000;
$t = -wfTime();
for ($i=0; $i<$n; $i++);
$t += wfTime();
print $t / $n * 1e6 . " us\n";


print "doBlockLevels: ";

$n = 50;
$t = -wfTime();
for ($j=0; $j<$n; $j++) {
        $wgParser->doBlockLevels( $text, true );
}
$t += wfTime();
print $t / $n * 1000 . " ms\n";

print "doTableStuff: ";

$n = 1000;
$t = -wfTime();
for ($j=0; $j<$n; $j++) {
        $wgParser->doTableStuff( $text );
}
$t += wfTime();
print $t / $n * 1000 . " ms\n";


print "String concatenation x1000: ";

$n = 10000;
$c = 1000;
$t = -wfTime();
for ($i=0; $i<$n; $i++) {
        $s = '';
        for ($j=0; $j<$c; $j++) {
                $s .= ' ';
        }
}
$t += wfTime();
print $t / $n * 1000 . " ms\n";

print "NFC: ";

$n = 50;
$t = -wfTime();
for ($j=0; $j<$n; $j++) {
        UtfNormal::NFC( $zhtext );
}
$t += wfTime();
print $t / $n * 1000 . " ms\n";

print "preg_replace: ";

$n = 1000;
$t = -wfTime();
for ($j=0; $j<$n; $j++) {
        preg_replace( '/[a-d]/', 'XX', $text );
}
$t += wfTime();
print $t / $n * 1000 . " ms\n";


/*
# Disabled due to high variability -- depends heavily on database and memcached

print "Parse: ";
$po = new ParserOptions;
$wgUseImageResize = false;

# Fill cache
$wgParser->parse( $text, $wgTitle, $po );

$wgDebugLogFile = '/dev/stdout';
foreach ( $wgLoadBalancer->mServers as $i => $server ) {
        $wgLoadBalancer->mServers[$i]['flags'] |= DBO_DEBUG;
}


$n = 20;
$t = -wfTime();
for ($j=0; $j<$n; $j++) {
        $wgParser->parse( $text, $wgTitle, $po );
}
$t += wfTime();
print $t / $n * 1000 . " ms\n";
*/
?>