Files
gitx/speed_test/malloc.c
T
Pieter de Bie 061eb7de48 Grapher: add speed tests
This creates a new directory speed_test with different
implementations that we can use to power the grapher. The current
implementation is somewhat lacking in that we build up the graph
completely at the end. If we can do it while traversing the tree, we
can build and display it earlier. Similarly, if we can leave out the
line calculation but just work with the columns, we save computation at
load time, and can defer the lines to the drawing process. That will
also clear up the problem of not being able to draw some lines.
2008-06-21 13:41:55 +02:00

48 lines
1.2 KiB
C

#include <stdlib.h>
#include <stdio.h>
#include <xlocale.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
struct list {
struct hash* columns;
int numColumns;
};
struct hash {
char value[40];
};
int main() {
srandomdev();
int i = 0; struct list* last;
int num = atoi("8000000");
int size = 1000;
/* Initialize initial list of revisions */
struct list** revisionList = malloc(size * sizeof(struct list*));
struct hash standardColumn;
strcpy(standardColumn.value, "Haha pieter");
for (i = 0; i < num; i++) {
if (size <= i) {
size *= 2;
revisionList = realloc(revisionList, size * sizeof(struct list*));
}
struct list* a = malloc(sizeof(struct list));
revisionList[i] = a;
a->numColumns = i % 5;
a->columns = malloc(a->numColumns * sizeof(struct hash));
int j;
for (j = 0; j < a->numColumns; j++) {
//ccolumns[currentColumn++] = st
strncpy(a->columns[j].value, "Haha pieter is cool", 20);
}
}
printf("Num value at 3000 is: %i vs %i\n", revisionList[3000]->numColumns, (int) (5 * random()));
return 0;
}