示例#1
0
文件: sky_bench.c 项目: dasfaha/sky
int main(int argc, char **argv)
{
    struct timeval tv;

    // Parse command line options.
    Options *options = parseopts(argc, argv);

    // Start time.
    gettimeofday(&tv, NULL);
    int64_t t0 = (tv.tv_sec*1000) + (tv.tv_usec/1000);

    // Benchmark computation of a DAG.
    // benchmark_dag(options);
    benchmark_count_with_qip(options);

    // End time.
    gettimeofday(&tv, NULL);
    int64_t t1 = (tv.tv_sec*1000) + (tv.tv_usec/1000);

    // Show wall clock time.
    printf("Elapsed Time: %.3f seconds\n", ((float)(t1-t0))/1000);

    // Clean up.
    Options_free(options);
    
    return 0;
}
示例#2
0
/*
 * Parse all command line arguments
 * and read the server defaults file and map file.
 * Then convert the map data into a World structure.
 */
bool Parser(int argc, char **argv)
{
    int i;
    char *fname;
    option_desc *desc;

    options.mapData = NULL;
    options.mapWidth = 0;
    options.mapHeight = 0;

    if (Init_options() == false)
	return false;

    for (i = 1; i < argc; i++) {
	if (Parse_check_info_request(argv, i))
	    return false;

	if (argv[i][0] == '-' || argv[i][0] == '+') {
	    desc = Find_option_by_name(argv[i] + 1);
	    if (desc != NULL) {
		if (desc->type == valBool) {
		    const char *bool_value;

		    if (argv[i][0] == '-')
			bool_value = "true";
		    else
			bool_value = "false";
		    Option_set_value(desc->name, bool_value, 1, OPT_COMMAND);
		}
		else if (desc->type == valVoid)
		    ;
		else {
		    if (i + 1 == argc)
			warn("Option '%s' needs an argument", argv[i]);
		    else {
			i++;
			Option_set_value(desc->name, argv[i], 1, OPT_COMMAND);
		    }
		}
	    }
	    else
		warn("Unknown option '%s'", argv[i]);
	}
	else
	    warn("Unknown option '%s'", argv[i]);
    }

    /*
     * Read local defaults file
     */
    if ((fname = Option_get_value("defaultsFileName", NULL)) != NULL)
	parseDefaultsFile(fname);
    else
	parseDefaultsFile(Conf_defaults_file_name());

    /*
     * Read local password file
     */
    if ((fname = Option_get_value("passwordFileName", NULL)) != NULL)
	parsePasswordFile(fname);
    else
	parsePasswordFile(Conf_password_file_name());

    /*
     * Read map file if map data not found yet.
     *
     * If "mapFileName" is defined then read it's contents from file.
     * Else read a default map.
     */
    if (!(fname = Option_get_value("mapData", NULL))) {
	if ((fname = Option_get_value("mapFileName", NULL)) != NULL) {
	    if (!parseMapFile(fname)) {
		xpprintf("Unable to read %s, trying to open %s\n",
			 fname, Conf_default_map());
		if (!parseMapFile(Conf_default_map()))
		    xpprintf("Unable to read %s\n", Conf_default_map());
	    }
	} else {
	    xpprintf("Map not specified, trying to open %s\n",
		     Conf_default_map());
	    if (!parseMapFile(Conf_default_map()))
		xpprintf("Unable to read %s\n", Conf_default_map());
	}
    }
    /*
     * Parse the options database and 'internalise' it.
     */
    Options_parse();

    Options_free();

    /*
     * Construct the World structure from the options.
     */
    return Grok_map();
}