Extension:Cargo/DDB-SMW-Cargo-performance.php

From mediawiki.org

These are the contents of the file DDB-SMW-Cargo-performance.php, which has been used to do performance testing of Cargo.

<?php

const NUM_RUNS = 3;
const NUM_RETRIEVALS = 10;

function getExecutionTime( $urlName, $url ) {
        print "Getting $urlName data...";
        $startTime = time();
        for ( $i = 0; $i < NUM_RETRIEVALS; $i++ ) {
                file_get_contents( $url );
        }
        $endTime = time();
        print " took " . ( $endTime - $startTime ) . " seconds.\n";
}

$urls = array(
        'SMW' => "http://discoursedb.org/wiki/Special:Ask?q=%5B%5BCategory%3AItems%5D%5D%5B%5BWas+published+by%3A%3AThe+Wall+Street+Journal%5D%5D&po=%3FWas+written+by%3DAuthor%0D%0A%3FWas+published+on%3DDate%0D%0A&eq=yes&p%5Bformat%5D=csv&sort%5B0%5D=Was+published+on&order%5B0%5D=ASC&sort_num=&order_num=ASC&p%5Blimit%5D=100&p%5Bsort%5D=Was+published+on&p%5Border%5D%5Bascending%5D=1&p%5Bheaders%5D=show&p%5Bmainlabel%5D=Item",
        'Cargo' => "http://discoursedb.org/wiki/Special:CargoExport?format=csv&tables=Items&fields=_pageName=Item,Author,Date&where=Source=%22The%20Wall%20Street%20Journal%22&limit=100&order%20by=Date%20ASC"
);

for ( $i = 0; $i < NUM_RUNS; $i++ ) {
        foreach ( $urls as $name => $url ) {
                getExecutionTime( $name, $url );
        }
}