Skip to content

Commit 8ece41a

Browse files
committed
refactor: rename ZAP_LOOP to ZAP_ITER
1 parent b2b759f commit 8ece41a

File tree

8 files changed

+29
-29
lines changed

8 files changed

+29
-29
lines changed

examples/example.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
/* Example benchmark: Empty loop baseline */
88
void bench_empty(zap_t* z) {
9-
ZAP_LOOP(z) {
9+
ZAP_ITER(z) {
1010
/* Empty - measures loop overhead */
1111
}
1212
}
1313

1414
/* Example benchmark: Simple arithmetic */
1515
void bench_arithmetic(zap_t* z) {
1616
int x = 0;
17-
ZAP_LOOP(z) {
17+
ZAP_ITER(z) {
1818
x = x + 1;
1919
x = x * 2;
2020
x = x - 1;
@@ -38,7 +38,7 @@ static int fibonacci(int n) {
3838
void bench_fibonacci(zap_t* z) {
3939
int n = z->param ? *(int*)z->param : 10;
4040
int result;
41-
ZAP_LOOP(z) {
41+
ZAP_ITER(z) {
4242
result = fibonacci(n);
4343
zap_black_box(result);
4444
}
@@ -53,7 +53,7 @@ void bench_compute(zap_t* z) {
5353
}
5454
zap_black_box(data);
5555

56-
ZAP_LOOP(z) {
56+
ZAP_ITER(z) {
5757
double sum = 0.0;
5858
for (int i = 0; i < 256; i++) {
5959
sum += data[i] * data[i];
@@ -65,7 +65,7 @@ void bench_compute(zap_t* z) {
6565
/* Example benchmark: Memory allocation */
6666
void bench_malloc(zap_t* z) {
6767
size_t size = z->param ? *(size_t*)z->param : 64;
68-
ZAP_LOOP(z) {
68+
ZAP_ITER(z) {
6969
void* p = malloc(size);
7070
zap_black_box(p);
7171
free(p);
@@ -83,7 +83,7 @@ void bench_memcpy_1mb(zap_t* z) {
8383
/* Set throughput: each iteration copies COPY_SIZE bytes */
8484
zap_set_throughput_bytes(z, COPY_SIZE);
8585

86-
ZAP_LOOP(z) {
86+
ZAP_ITER(z) {
8787
memcpy(dst, src, COPY_SIZE);
8888
zap_black_box(dst);
8989
}
@@ -98,7 +98,7 @@ void bench_memset_1mb(zap_t* z) {
9898
/* Set throughput: each iteration writes COPY_SIZE bytes */
9999
zap_set_throughput_bytes(z, COPY_SIZE);
100100

101-
ZAP_LOOP(z) {
101+
ZAP_ITER(z) {
102102
memset(dst, 'x', COPY_SIZE);
103103
zap_black_box(dst);
104104
}

examples/example_advanced.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void bubble_sort(int* arr, size_t n) {
4848
static void bench_fib(zap_t* z) {
4949
int n = z->param ? *(int*)z->param : 10;
5050
int result;
51-
ZAP_LOOP(z) {
51+
ZAP_ITER(z) {
5252
result = fibonacci(n);
5353
zap_black_box(result);
5454
}
@@ -64,7 +64,7 @@ typedef struct {
6464
static void bench_sort(zap_t* z) {
6565
sort_input_t* input = (sort_input_t*)z->param;
6666

67-
ZAP_LOOP(z) {
67+
ZAP_ITER(z) {
6868
memcpy(input->work, input->data, input->size * sizeof(int));
6969
bubble_sort(input->work, input->size);
7070
zap_black_box(input->work);
@@ -75,7 +75,7 @@ static void bench_sort(zap_t* z) {
7575
static void bench_malloc(zap_t* z) {
7676
size_t size = z->param ? *(size_t*)z->param : 64;
7777

78-
ZAP_LOOP(z) {
78+
ZAP_ITER(z) {
7979
void* p = malloc(size);
8080
zap_black_box(p);
8181
free(p);

examples/example_ci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/* Benchmark: allocation performance */
1919
void bench_malloc(zap_t* z) {
2020
size_t size = z->param ? *(size_t*)z->param : 64;
21-
ZAP_LOOP(z) {
21+
ZAP_ITER(z) {
2222
void* p = malloc(size);
2323
zap_black_box(p);
2424
free(p);

examples/example_compare.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void reset_array(int* arr, size_t n) {
4848
void bench_qsort(zap_t* z) {
4949
sort_ctx_t* ctx = (sort_ctx_t*)z->param;
5050

51-
ZAP_LOOP(z) {
51+
ZAP_ITER(z) {
5252
reset_array(ctx->arr, ctx->n);
5353
qsort(ctx->arr, ctx->n, sizeof(int), cmp_int);
5454
zap_black_box(ctx->arr);
@@ -73,7 +73,7 @@ static void bubble_sort(int* arr, size_t n) {
7373
void bench_bubble(zap_t* z) {
7474
sort_ctx_t* ctx = (sort_ctx_t*)z->param;
7575

76-
ZAP_LOOP(z) {
76+
ZAP_ITER(z) {
7777
reset_array(ctx->arr, ctx->n);
7878
bubble_sort(ctx->arr, ctx->n);
7979
zap_black_box(ctx->arr);
@@ -98,7 +98,7 @@ static void insertion_sort(int* arr, size_t n) {
9898
void bench_insertion(zap_t* z) {
9999
sort_ctx_t* ctx = (sort_ctx_t*)z->param;
100100

101-
ZAP_LOOP(z) {
101+
ZAP_ITER(z) {
102102
reset_array(ctx->arr, ctx->n);
103103
insertion_sort(ctx->arr, ctx->n);
104104
zap_black_box(ctx->arr);
@@ -120,7 +120,7 @@ void bench_memcpy(zap_t* z) {
120120
// Report throughput in bytes/sec
121121
zap_set_throughput_bytes(z, ctx->n);
122122

123-
ZAP_LOOP(z) {
123+
ZAP_ITER(z) {
124124
memcpy(ctx->dst, ctx->src, ctx->n);
125125
zap_black_box(ctx->dst);
126126
}
@@ -132,7 +132,7 @@ void bench_memmove(zap_t* z) {
132132
// Report throughput in bytes/sec
133133
zap_set_throughput_bytes(z, ctx->n);
134134

135-
ZAP_LOOP(z) {
135+
ZAP_ITER(z) {
136136
memmove(ctx->dst, ctx->src, ctx->n);
137137
zap_black_box(ctx->dst);
138138
}
@@ -144,7 +144,7 @@ void bench_manual_copy(zap_t* z) {
144144
// Report throughput in bytes/sec
145145
zap_set_throughput_bytes(z, ctx->n);
146146

147-
ZAP_LOOP(z) {
147+
ZAP_ITER(z) {
148148
for (size_t i = 0; i < ctx->n; i++) {
149149
ctx->dst[i] = ctx->src[i];
150150
}

examples/example_micro.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
/* Benchmark: empty loop (measures overhead) */
1919
void bench_noop(zap_t* z) {
20-
ZAP_LOOP(z) {
20+
ZAP_ITER(z) {
2121
/* Empty - measures loop overhead */
2222
}
2323
}
@@ -26,7 +26,7 @@ void bench_noop(zap_t* z) {
2626
void bench_int_add(zap_t* z) {
2727
int x = 0;
2828
zap_black_box(x);
29-
ZAP_LOOP(z) {
29+
ZAP_ITER(z) {
3030
x = x + 1;
3131
zap_black_box(x);
3232
}
@@ -36,7 +36,7 @@ void bench_int_add(zap_t* z) {
3636
void bench_int_mul(zap_t* z) {
3737
int x = 1;
3838
zap_black_box(x);
39-
ZAP_LOOP(z) {
39+
ZAP_ITER(z) {
4040
x = x * 3;
4141
zap_black_box(x);
4242
}
@@ -46,7 +46,7 @@ void bench_int_mul(zap_t* z) {
4646
void bench_int_div(zap_t* z) {
4747
int x = 1000000;
4848
zap_black_box(x);
49-
ZAP_LOOP(z) {
49+
ZAP_ITER(z) {
5050
x = x / 2;
5151
if (x == 0) x = 1000000;
5252
zap_black_box(x);
@@ -57,7 +57,7 @@ void bench_int_div(zap_t* z) {
5757
void bench_float_mul(zap_t* z) {
5858
double x = 1.5;
5959
zap_black_box(x);
60-
ZAP_LOOP(z) {
60+
ZAP_ITER(z) {
6161
x = x * 1.000001;
6262
zap_black_box(x);
6363
}

examples/example_quick.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
void bench_example(zap_t* z) {
1717
int x = 0;
18-
ZAP_LOOP(z) {
18+
ZAP_ITER(z) {
1919
x = x + 1;
2020
x = x * 2;
2121
zap_black_box(x);

examples/example_verbose.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void bench_memcpy(zap_t* z) {
2626

2727
zap_set_throughput_bytes(z, COPY_SIZE);
2828

29-
ZAP_LOOP(z) {
29+
ZAP_ITER(z) {
3030
memcpy(dst, src, COPY_SIZE);
3131
zap_black_box(dst);
3232
}
@@ -43,7 +43,7 @@ void bench_compute(zap_t* z) {
4343
}
4444
zap_black_box(data);
4545

46-
ZAP_LOOP(z) {
46+
ZAP_ITER(z) {
4747
double sum = 0.0;
4848
for (int i = 0; i < 64; i++) {
4949
sum += data[i] * data[i];

zap.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* EXAMPLE:
1515
* void bench_example(zap_t* z) {
1616
* int n = z->param ? *(int*)z->param : 10;
17-
* ZAP_LOOP(z) {
17+
* ZAP_ITER(z) {
1818
* result = do_work(n);
1919
* zap_black_box(result);
2020
* }
@@ -419,13 +419,13 @@ void zap_compare_group_finish(zap_compare_group_t* g);
419419
/* MACROS */
420420

421421
/*
422-
* ZAP_LOOP - Main benchmarking loop
422+
* ZAP_ITER - Main benchmarking loop
423423
* Usage:
424-
* ZAP_LOOP(c) {
424+
* ZAP_ITER(c) {
425425
* // code to benchmark
426426
* }
427427
*/
428-
#define ZAP_LOOP(c) \
428+
#define ZAP_ITER(c) \
429429
for (int _crit_done = 0; !_crit_done; ) \
430430
for (; zap_loop_start(c); _crit_done = 1, zap_loop_end(c)) \
431431
for (uint64_t _crit_i = 0; _crit_i < (c)->iterations; ++_crit_i)

0 commit comments

Comments
 (0)