コード例 #1
0
int main(void)
{
	int i;
	map *m;
	int lastcap;
	stats s;
	stat_list *l1, *l2;
	stat_list_iterator iter;
	double _max_load[] = {0.2, 0.3, 0.5, 0.7, 0.85, 1.0, 1.15, 1.3, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 6.0, 9.0, 12.0, 15.0, 20.0, 0.0};
	double *max_load = _max_load;

	l1 = stat_list_new();
	l2 = stat_list_new();
	while (*max_load > 0) {
		m = map_new();
		m->max_load = *max_load;
		++max_load;
		lastcap = m->cap;
		s = map_stats(m);
		srand(0);
		for (i=0; i<=N; ++i) {
			while (m->cap == lastcap) {
				if ((m->len+1.0)/m->cap > m->max_load) {
					s = map_stats(m);
				}
				map_set(m, randt(), randt());
			}
			lastcap = m->cap;
		}
		stat_list_insert(l1, s, -1);
		stat_list_insert(l2, map_stats(m), -1);
		map_free(m);
	}

	print_header();
	print_hr();
	for (iter=stat_list_iterate(l1); stat_list_next(l1, &iter); ) {
		print_stats(stat_list_get_at(l1, iter));
	}
	print_hr();
	print_header();
	print_hr();
	for (iter=stat_list_iterate(l2); stat_list_next(l2, &iter); ) {
		print_stats(stat_list_get_at(l2, iter));
	}

	stat_list_free(l1);
	stat_list_free(l2);

	return 0;
}
コード例 #2
0
ファイル: hr.c プロジェクト: gaebor/human_readable
int hr_gibi_P(char* result, int out_buffer_size, float num, const char* suffix)
{
    static const char* units[] = { "",  "ki",  "Mi",  "Gi",  "Ti",  "Pi",  "Ei",  "Zi",  "Yi" };
    static const float changes[] = { 1,  1024,  1024,  1024,  1024,  1024,  1024,  1024,  1024, 0 };

    return print_hr(result, out_buffer_size, num, changes, units, "%.4g%s%s", suffix);
}
コード例 #3
0
ファイル: hr.c プロジェクト: gaebor/human_readable
int hr_time_P(char* result, int out_buffer_size, float num, const char* suffix)
{
    static const char* units[] = { "ns",  "us",  "ms",  "sec",  "min",  "h",  "day",  "yrs" };
    static const float changes[] = { 1e-9f,1000, 1000,   1000,     60,   60,     24,   365, 0 };

    return print_hr(result, out_buffer_size, num, changes, units, "%.3g%s%s", suffix);
}
コード例 #4
0
ファイル: hr.c プロジェクト: gaebor/human_readable
int hr_giga_P(char* result, int out_buffer_size, float num, const char* suffix)
{
    static const char* units[] = { "",  "k",  "M",  "G",  "T",  "P",  "E",  "Z",  "Y" };
    static const float changes[] = { 1, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0 };

    return print_hr(result, out_buffer_size, num, changes, units, "%.4g%s%s", suffix);
}
コード例 #5
0
int handle_word(char buf[], FILE *files[], struct sc_config const *config)
{
    int ret = -1;
    char tmp[strlen(buf)];
    char inp[MAX_WORD_LENGTH];
    trim_word(buf, tmp);
    if (is_number(tmp))
        goto NEXT;
    if (word_exists(files[FILE_DIC], tmp)) {
        fprintf(files[FILE_OUT], "%s", buf);
    } else {
        printf(CLSCRN);
        print_header(config->file[FILE_DOC]);
        print_hr();
        print_preview(files[FILE_DOC], buf);
        print_hr();
        printf("word \"%s\" not found in dict\n", tmp);
        print_progress(files[FILE_DOC]);
        switch (show_menu()) {
        case 'a':
            fprintf(files[FILE_DIC], "%s\n", tmp);
            fprintf(files[FILE_OUT], "%s", tmp);
            break;
        case 's':
            printf("substitute %s: ", buf);
            input_line(inp, sizeof(inp));
            fprintf(files[FILE_OUT], "%s", inp);
            break;
        case 'c':
            fprintf(files[FILE_OUT], "%s", buf);
            break;
        case 'q':
            goto ERROR;
        }
    }

NEXT:
    ret = 0;

ERROR:
    return ret;
}