grub2: bring back build of aros-side grub2 tools
[AROS.git] / test / benchmarks / exec / allocvec.c
blob45663ad1aec5077bdd8fc33e94cf21a973335695
1 /*
2 Copyright © 2003-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <sys/time.h>
7 #include <stdio.h>
8 #include <string.h>
10 #include <exec/types.h>
11 #include <exec/memory.h>
12 #include <proto/exec.h>
14 int main()
16 struct timeval tv_start,
17 tv_end;
18 int count = 10000000;
19 double elapsed = 0.0;
20 int i;
21 APTR memory;
23 gettimeofday(&tv_start, NULL);
25 for(i = 0; i < count; i++)
27 memory = AllocVec(100, MEMF_ANY);
28 FreeVec(memory);
31 gettimeofday(&tv_end, NULL);
33 elapsed = ((double)(((tv_end.tv_sec * 1000000) + tv_end.tv_usec)
34 - ((tv_start.tv_sec * 1000000) + tv_start.tv_usec)))/1000000.;
36 printf
38 "Elapsed time: %f seconds\n"
39 "Number of allocations: %d\n"
40 "Allocations per second: %f\n"
41 "Seconds per allocation: %f\n",
42 elapsed, count, (double) count / elapsed, (double) elapsed / count
45 return 0;