Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "stdlib.h"
- #include "time.h"
- //stream blocks experiment
- //block structure
- struct stream {
- void *data[10];
- unsigned short type[10];
- int len[10];
- //next block of data
- struct stream* next;
- };
- typedef struct stream stream;
- stream* allocate(int amount)
- {
- return (stream*)malloc(sizeof(stream) * amount);
- }
- int main(void) {
- int i = 200000;
- clock_t start = clock(), diff;
- stream* root = (stream*)malloc(sizeof(stream));
- stream* travel = root;
- while(i--)
- {
- travel->data[0] = malloc(sizeof(int));
- travel->next = (stream*)malloc(sizeof(stream));
- travel = travel->next;
- }
- diff = clock() - start;
- int msec = diff * 1000 / CLOCKS_PER_SEC;
- printf("Time taken %d seconds %d milliseconds", msec/1000, msec%1000);
- //25 ms for 2million array of integers
- printf("sizeof stream = %d", sizeof(stream));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement