#include #include #include #include "timer.h" struct node_t { struct node_t* next; uint64_t data; }; int main(int argc, char* argv[]) { if (argc < 2) abort(); int n = atol(argv[1]); timer_start(); struct node_t list = { NULL, -1ull }; struct node_t* it = &list; for (int i = 0; i < n; ++i) { it->data = i; it->next = (struct node_t*) malloc(sizeof(struct node_t)); it = it->next; } it->next = NULL; unsigned long elapsed1 = timer_stop(); timer_start(); it = &list; while (it) { ++(it->data); it = it->next; } unsigned long elapsed2 = timer_stop(); printf("Fill: %lu usec\n", elapsed1); printf("Inc: %lu usec\n", elapsed2); printf("Total: %lu usec\n", elapsed1 + elapsed2); return 0; }