Fixed UHCI port bits for big endian machines.
[cake.git] / test / benchmarks / exec / allocpooled.c
blobfff7cb174d2bdc48e6bb9454953ba4f23ac68a26
1 /*
2 Copyright © 2003, 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 = 100000000;
19 double elapsed = 0.0;
20 int i;
21 APTR pool;
22 APTR memory;
24 pool = CreatePool(MEMF_ANY, 4 * 100, 100);
25 AllocPooled(pool, 100); // Avoid bad behaviour of FreePooled()
27 gettimeofday(&tv_start, NULL);
29 for(i = 0; i < count; i++)
31 memory = AllocPooled(pool, 100);
32 if (memory) FreePooled(pool, memory, 100);
35 gettimeofday(&tv_end, NULL);
37 DeletePool(pool);
39 elapsed = ((double)(((tv_end.tv_sec * 1000000) + tv_end.tv_usec)
40 - ((tv_start.tv_sec * 1000000) + tv_start.tv_usec)))/1000000.;
42 printf
44 "Elapsed time: %f seconds\n"
45 "Number of allocations: %d\n"
46 "Allocations per second: %f\n"
47 "Seconds per allocation: %f\n",
48 elapsed, count, (double) count / elapsed, (double) elapsed / count
51 return 0;