All pastes #403444 Raw Edit

Stuff

public c v1 · immutable
·published 2007-03-20 11:33 UTC
rendered paste body
#include <mowgli.h>#include <glib.h>void bench(int iterations){	double start, end;	struct timeval tv;	int i;	mowgli_list_t l;	GList *list = NULL;	printf("%d iterations:\n", iterations);	gettimeofday(&tv, NULL);	start = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;	for (i = 0; i < iterations; i++)		list = g_list_append(list, NULL);	gettimeofday(&tv, NULL);	end = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;	printf("      GList: %.10f\t", end - start);	gettimeofday(&tv, NULL);	start = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;	for (i = 0; i < iterations; i++)		mowgli_node_add(NULL, mowgli_node_create(), &l);	gettimeofday(&tv, NULL);	end = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;	printf("     Mowgli: %.10f\n", end - start);}int main(int argc, char *argv[]){	int i;	mowgli_init();	printf("\"GList\" vs mowgli_list_t test.\n");	printf("GList is in quotes because it's actually a queue, and thus is expected to be O(n).\n");	printf("Scores are measured in seconds required to finish the job.\n");	bench(100);	bench(1000);	bench(10000);	bench(25000);	bench(50000);	bench(100000);}