Beispiel #1
0
require_once dirname(__FILE__) . '/BlockStorageTest.php';
require_once dirname(__FILE__) . '/save/BenchmarkDb.php';
$status = 1;
$args = parse_args(array('iteration:', 'nosave_fio', 'nostore_json', 'nostore_pdf', 'nostore_rrd', 'nostore_zip', 'v' => 'verbose'));
// get result directories => each directory stores 1 iteration of results
$dirs = array();
$dir = count($argv) > 1 && is_dir($argv[count($argv) - 1]) ? $argv[count($argv) - 1] : trim(shell_exec('pwd'));
if (is_dir(sprintf('%s/1', $dir))) {
    $i = 1;
    while (is_dir($sdir = sprintf('%s/%d', $dir, $i++))) {
        $dirs[] = $sdir;
    }
} else {
    $dirs[] = $dir;
}
if ($db =& BenchmarkDb::getDb()) {
    $db->tablePrefix = 'block_storage_';
    // get results from each directory
    foreach ($dirs as $i => $dir) {
        $iteration = isset($args['iteration']) && preg_match('/([0-9]+)/', $args['iteration'], $m) ? $m[1] * 1 : $i + 1;
        print_msg(sprintf('Saving results in directory %s', $dir), isset($args['verbose']), __FILE__, __LINE__);
        // save report.pdf and report.zip
        foreach (array('nostore_pdf' => 'report.pdf', 'nostore_zip' => 'report.zip') as $arg => $file) {
            $file = sprintf('%s/%s', $dir, $file);
            if (!isset($args[$arg]) && file_exists($file)) {
                $pieces = explode('.', $file);
                $col = sprintf('report_%s', $pieces[count($pieces) - 1]);
                $saved = $db->saveArtifact($file, $col);
                if ($saved) {
                    print_msg(sprintf('Saved %s successfully', basename($file)), isset($args['verbose']), __FILE__, __LINE__);
                } else {
Beispiel #2
0
 /**
  * returns test results - an array of hashes each containing the results from
  * 1 test
  * @return array
  */
 public function getResults()
 {
     $results = NULL;
     require_once sprintf('%s/benchmark/save/BenchmarkDb.php', dirname(__FILE__));
     if ($db =& BenchmarkDb::getDb()) {
         $this->getRunOptions();
         if ($results = isset($this->options['results']) ? $this->options['results'] : NULL) {
             $schema = $db->getSchema('network');
             foreach (array_keys($this->options) as $key) {
                 if (isset($schema[$key]) && preg_match('/^meta/', $key)) {
                     foreach (array_keys($results) as $i) {
                         if (!isset($results[$i][$key])) {
                             $results[$i][$key] = trim(is_array($this->options[$key]) ? implode(' ', $this->options[$key]) : $this->options[$key]);
                             if (!$results[$i][$key]) {
                                 unset($results[$i][$key]);
                             }
                         } else {
                             if ($results[$i][$key] === FALSE) {
                                 unset($results[$i][$key]);
                             }
                         }
                     }
                 }
             }
         }
     }
     return $results;
 }