コード例 #1
0
ファイル: graphPerformance.C プロジェクト: Sciumo/rose
int
main(int argc, char *argv[])
{
    // Dictionary of possible tests
    testDictionary.insert("sage",               run_sage);
    testDictionary.insert("sawyer",             run_sawyer);
    testDictionary.insert("sawyer-pool",        run_sawyer_pool);
    testDictionary.insert("sawyer-bgl",         run_sawyer_bgl);
    testDictionary.insert("sawyer-bgl-pool",    run_sawyer_bgl_pool);
    testDictionary.insert("bgl-vec-vec",        run_bgl_vec_vec);
    testDictionary.insert("bgl-vec-list",       run_bgl_vec_list);
    testDictionary.insert("bgl-vec-set",        run_bgl_vec_set);
    testDictionary.insert("yagi",               run_yagi);
    testDictionary.insert("yagi-bidir",         run_yagi_bidir);
    testDictionary.insert("yagi-bgl",           run_yagi_bgl);
    testDictionary.insert("yagi-bgl-bidir",     run_yagi_bgl_bidir);
    testDictionary.insert("sage-inc",           run_sage_inc);
    testDictionary.insert("sage-inc-bidir",     run_sage_inc_bidir);

    // Parse command-line
    using Sawyer::CommandLine::Switch;
    Sawyer::CommandLine::SwitchGroup switches;
    switches.insert(Switch("help", 'h')
                    .action(userAction(showHelpAndExit))
                    .doc("Shows this documentation."));
    switches.insert(Switch("iterations", 'N')
                    .argument("n", Sawyer::CommandLine::integerParser(nruns))
                    .doc("Run the tests @v{N} times each."));
    switches.insert(Switch("list", 'L')
                    .action(userAction(listTestsAndExit))
                    .doc("List the available tests and exit."));
    Sawyer::CommandLine::Parser parser;
    parser.with(switches);
    parser.purpose("tests performance of various graph implementations");
    parser.doc("Synopsis", "@prop{programName} [@v{switches}...] @v{test_names}...");
    Sawyer::CommandLine::ParserResult cmdline = parser.parse(argc, argv).apply();

    // Run each specified test
    BOOST_FOREACH (const std::string &testName, cmdline.unreachedArgs()) {
        if (testName == "all") {
            BOOST_FOREACH (void(*func)(), testDictionary.values())
                func();
        } else if (void(*func)() = testDictionary.getOrElse(testName, NULL)) {
            func();
        } else {
            std::cerr <<"unknown graph type: " <<testName <<"\n"
                      <<"use --list to see a list of types\n";
        }
    }

    return 0;
}
コード例 #2
0
void
CommandlineProcessing::insertBooleanSwitch(Sawyer::CommandLine::SwitchGroup &sg, const std::string &switchName,
                                           bool &storageLocation, const std::string &documentation) {
    using namespace Sawyer::CommandLine;

    ASSERT_forbid2(boost::starts_with(switchName, "-"), "specify only the name, not the prefix");

    std::string defaults = " This can be disabled with @s{no-" + switchName + "}. The default is " +
                           (storageLocation ? "yes" : "no") + ".";

    sg.insert(Switch(switchName)
              .intrinsicValue(true, storageLocation)
              .doc(documentation + defaults));
    sg.insert(Switch("no-"+switchName)
              .key(switchName)
              .intrinsicValue(false, storageLocation)
              .hidden(true));
}
コード例 #3
0
ファイル: graph_test_1.C プロジェクト: alexjohn1362/rose
int main(int argc, char *argv[]) {

    size_t nverts = 1000;                               // number of vertices to insert
    bool skipEdges = false;                             // if true, then skip the step that inserts edges
    
    // Parse command-line
    using Sawyer::CommandLine::Switch;
    Sawyer::CommandLine::SwitchGroup switches;
    switches.insert(Switch("help", 'h')
                    .action(userAction(showHelpAndExit))
                    .doc("Shows this documentation."));
    switches.insert(Switch("nverts", 'v')
                    .argument("n", Sawyer::CommandLine::integerParser(nverts))
                    .doc("Populate the graph with @v{n} vertices. The default is " + lexical_cast<string>(nverts) + "."));
    switches.insert(Switch("no-edges")
                    .intrinsicValue(true, skipEdges)
                    .doc("Do not add edges to the graph.  The default, when this switch is not present, is to add a "
                         "directed edge from vertex i to vertex j for all i<j."));
    Sawyer::CommandLine::Parser parser;
    parser.with(switches);
    parser.purpose("tests vertex and edge insertion for Sage vs. Sawyer graphs");
    parser.doc("Synopsis", "@prop{programName} [@v{switches}...] sage|sawyer...");
    Sawyer::CommandLine::ParserResult cmdline = parser.parse(argc, argv).apply();

    if (cmdline.unparsedArgs().size() != 1) {
        std::cerr <<"incorrect usage; see --help\n";
        exit(1);
    }
    bool use_sage = 0==cmdline.unparsedArgs().front().compare("sage");
    
    if (use_sage) {
        print_sage_graph_info();
        test_sage_graph(nverts, skipEdges);
    } else {
        print_sawyer_graph_info();
        test_sawyer_graph(nverts, skipEdges);
    }

    return 0;
}