Created
October 21, 2015 01:20
-
-
Save arr2036/0db406b3adbfc3b3bfbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <talloc.h> | |
#include <stdio.h> | |
#include <time.h> | |
#include <stdlib.h> | |
#include <inttypes.h> | |
int main(int argc, char **argv) | |
{ | |
uint64_t i, j, max, step; | |
clock_t begin, end; | |
double time_spent; | |
TALLOC_CTX *ctx; | |
if (argc < 3) { | |
printf("Need %s <max> <step>\n", argv[0]); | |
return 1; | |
} | |
ctx = talloc_init("main"); | |
max = strtoul(argv[1], NULL, 10); | |
step = strtoul(argv[2], NULL, 10); | |
printf("Performing %" PRIu64" (%s) allocs\n", max, argv[1]); | |
for (i = 0; i <= max; i += j) { | |
begin = clock(); | |
for (j = 0; j < step; j++) { | |
talloc_array(ctx, uint8_t, 1); | |
} | |
end = clock(); | |
time_spent = (double)(end - begin) / CLOCKS_PER_SEC; | |
printf("%" PRIu64 ",%f\n", i, time_spent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment