コード例 #1
0
ファイル: ubertest.php プロジェクト: ravelry/sphinx
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
if (!$run) {
    print "ERROR: no run mode defined; run with no arguments for help screen.\n";
    exit(1);
}
PublishLocals($locals, false);
GuessIdSize();
GuessRE2();
GuessRLP();
GuessODBC();
if ($g_locals["malloc-scribble"]) {
    print "Malloc scribbling enabled.\n";
    putenv("MallocLogFile=/dev/null");
    putenv("MallocScribble=1");
    putenv("MallocPreScribble=1");
    putenv("MallocGuardEdges=1");
}
require_once "helpers.inc";
/////////////
// run tests
/////////////
コード例 #2
0
ファイル: bench.php プロジェクト: hanbingtel/Coreseek-Fix
function Main($argv)
{
    if (count($argv) == 1) {
        BenchPrintHelp($argv[0]);
        return 0;
    }
    $mode = null;
    $files = array();
    $locals = array();
    // parse arguments
    $force_reindex = false;
    $view_results = false;
    $unlink_run = false;
    for ($i = 1; $i < count($argv); $i++) {
        $opt = $argv[$i];
        if (substr($opt, 0, 2) == '--') {
            $values = explode('=', substr($opt, 2), 2);
            if (count($values) == 2) {
                $locals[$values[0]] = $values[1];
            }
        } else {
            if ($opt[0] == '-' && $i < count($argv) - 1) {
                $locals[substr($opt, 1)] = $argv[++$i];
            } else {
                if ($mode) {
                    $files[] = $opt;
                } else {
                    switch ($opt) {
                        case 'b':
                        case 'benchmark':
                            $mode = 'benchmark';
                            break;
                        case 'bb':
                            $mode = 'benchmark';
                            $force_reindex = true;
                            break;
                        case 'bv':
                            $mode = 'benchmark';
                            $view_results = true;
                            break;
                        case 'bbv':
                            $mode = 'benchmark';
                            $force_reindex = true;
                            $view_results = true;
                            break;
                        case 'c':
                        case 'compare':
                            $mode = 'compare';
                            break;
                        case 't':
                        case 'try':
                            $mode = 'benchmark';
                            $view_results = true;
                            $unlink_run = true;
                            break;
                        case 'v':
                        case 'view':
                            $mode = 'view';
                            break;
                        default:
                            Fatal("unknown mode '{$opt}' (run bench.php without arguments for help)");
                    }
                }
            }
        }
    }
    global $g_locals;
    PublishLocals($locals, true);
    require_once "helpers.inc";
    // run the command
    if ($mode == 'benchmark') {
        if (count($files) == 0) {
            $avail = AvailableBenchmarks();
            if ($avail) {
                $avail = " ({$avail})";
            }
            Fatal("benchmark command requires a benchmark name{$avail}");
        }
        if (count($files) != 1) {
            Fatal("benchmark command requires exactly one name");
        }
        $path = "bench/{$files['0']}.xml";
        if (!is_readable($path)) {
            Fatal("benchmark scenario '{$path}' is not readable");
        }
        $res = sphBenchmark($files[0], $g_locals, $force_reindex);
        if (!$res) {
            return 1;
        }
        if ($view_results) {
            sphTextReport(sphCompare(array("{$res}.bin", "{$res}.bin")));
        }
        if ($unlink_run) {
            printf("\nunlinked %s\n", $res);
            unlink("{$res}.bin");
            unlink("{$res}.searchd.txt");
        }
    } else {
        if ($mode == 'compare') {
            switch (count($files)) {
                case 1:
                    // pick two freshest by name
                    $runs = PickFreshest($files[0], 2);
                    if (count($runs) != 2) {
                        Fatal("not enough run files for '{$files['0']}' (needed 2, got " . count($runs) . ")");
                    }
                    break;
                case 2:
                    // explicit run names given
                    $runs = array(LookupRun($files[0]), LookupRun($files[1]));
                    break;
                case 3:
                    // explicit run names, shortcut syntax
                    $runs = array(LookupRun("{$files['0']}.{$files['1']}"), LookupRun("{$files['0']}.{$files['2']}"));
                    break;
                default:
                    Fatal("invalid compare syntax (expected 1 to 3 args, got " . count($files) . ")");
            }
            sphTextReport(sphCompare($runs));
        } else {
            if ($mode == 'view') {
                if (count($files) != 1) {
                    Fatal("view command requires exactly one argument");
                }
                $run = LookupRun($files[0]);
                sphTextReport(sphCompare(array($run, $run)));
            } else {
                BenchPrintHelp($argv[0]);
            }
        }
    }
}