| ci-bench: cross-platform CI race scaffold (rickub CI vs GitHub Actions) 0baf736 Olivier Girardot yesterday | 1 | /* |
| 2 | * main.c — the tiny C program the docker-build workload compiles. |
| 3 | * |
| 4 | * The BUILD is the benchmark (multi-stage, network fetch of build-base, gcc |
| 5 | * invocation, final image assembly). The program itself just does a |
| 6 | * deterministic FNV-1a pass so the binary is non-trivial and its output is |
| 7 | * stable across platforms: ci-bench-docker-a56ee6092483 |
| 8 | */ |
| 9 | |
| 10 | #include <stdio.h> |
| 11 | #include <stdint.h> |
| 12 | #include <string.h> |
| 13 | |
| 14 | #define ROUNDS 2000000u |
| 15 | #define SEED_LEN 64 |
| 16 | |
| 17 | static uint64_t fnv1a(uint64_t h, const unsigned char *data, size_t len) { |
| 18 | for (size_t i = 0; i < len; i++) { |
| 19 | h ^= data[i]; |
| 20 | h *= 1099511628211ULL; /* FNV prime */ |
| 21 | } |
| 22 | return h; |
| 23 | } |
| 24 | |
| 25 | int main(void) { |
| 26 | unsigned char seed[SEED_LEN]; |
| 27 | for (size_t i = 0; i < SEED_LEN; i++) |
| 28 | seed[i] = (unsigned char)(i * 31 + 7); |
| 29 | |
| 30 | uint64_t h = 1469598103934665603ULL; /* FNV offset basis */ |
| 31 | for (uint32_t r = 0; r < ROUNDS; r++) { |
| 32 | seed[0] = (unsigned char)(r & 0xff); |
| 33 | seed[1] = (unsigned char)((r >> 8) & 0xff); |
| 34 | h = fnv1a(h, seed, SEED_LEN); |
| 35 | } |
| 36 | |
| 37 | /* Expected: stable for the fixed seed/rounds above; printed so a runner |
| 38 | * log shows the binary actually executed. */ |
| 39 | printf("ci-bench-docker-%012llx\n", (unsigned long long)(h & 0xffffffffffffULL)); |
| 40 | return 0; |
| 41 | } |