MCPcopy Create free account
hub / github.com/codr7/hacktical-c / run_malloc

Function run_malloc

malloc2/benchmarks.c:10–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#define GET_SIZE() ((rand() % MAX_SIZE) + 1)
9
10static void run_malloc() {
11 int *ps[N];
12 hc_time_t t = hc_now();
13
14 for (int i = 0; i < N; i++) {
15 ps[i] = malloc(GET_SIZE());
16 }
17
18 for (int i = 0; i < N; i++) {
19 free(ps[i]);
20 }
21
22 hc_time_print(&t, "malloc: ");
23}
24
25static void run_bump() {
26 struct hc_bump_alloc a;

Callers 1

malloc2_benchmarksFunction · 0.85

Calls 2

hc_nowFunction · 0.85
hc_time_printFunction · 0.85

Tested by

no test coverage detected