diff options
| author | 2026-10-12 08:46:23 +0330 | |
|---|---|---|
| committer | 2026-10-12 08:46:23 +0330 | |
| commit | ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch) | |
| tree | 70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /tests/programs/fbench.zc | |
a
Diffstat (limited to 'tests/programs/fbench.zc')
| -rw-r--r-- | tests/programs/fbench.zc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/programs/fbench.zc b/tests/programs/fbench.zc new file mode 100644 index 0000000..1658ba7 --- /dev/null +++ b/tests/programs/fbench.zc @@ -0,0 +1,37 @@ +// float kernel, plain and o3. bench_float.sh times them. the letter picks the +// kernel and the digits are how many times to run it, same shape as bench.zc. +float poly(int n) { + float s = 0.0; + float x = 1.25; + int i = 0; + while (i < n) { + s = s + x * 1.5; + x = x * 0.5 + 1.0; + i = i + 1; + } + return s; +} +o3 float poly3(int n) { + float s = 0.0; + float x = 1.25; + int i = 0; + while (i < n) { + s = s + x * 1.5; + x = x * 0.5 + 1.0; + i = i + 1; + } + return s; +} +fn main() { + let which = get_c(), reps = 0, ch = get_c(), r = 0; + while (ch >= 48 && ch <= 57) { reps = reps * 10 + ch - 48; ch = get_c(); } + while (reps > 0) { + if (which == 97) r = (int)poly(20000); + if (which == 98) r = (int)poly3(20000); + if (which == 99) r = (int)poly(2000); + reps = reps - 1; + } + put_n(r); + put_c(10); + return 0; +} |
