aboutsummaryrefslogtreecommitdiff
path: root/docs/history/15-o3/code/tests/bench.zc
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 09:09:21 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 09:09:21 +0330
commitdc7f7407e08f54e4a2a3c1d1723b2a7d6959532d (patch)
treed1de9f471a99951c57896f85b5e5523eeb96cee1 /docs/history/15-o3/code/tests/bench.zc
parenttodo: sync docs, examples and fixtures with the include format, and test acto... (diff)
docs: archive the frozen stage code as one compressed tarball
docs/history kept six stages with a full copy of the project under code/, 3.8 mb of sources duplicated from stage to stage and already superseded. store them as docs/history/code-snapshots.tar.gz, 0.66 mb, and extract one in place to read it. every stage's notes.md stays browsable, and the index says where the code went and how to get it back. the top-level README points at the archive too. its other two links into docs/history, 21-micro and 35-bench, were notes that were never kept and do not resolve; the index now records that.
Diffstat (limited to 'docs/history/15-o3/code/tests/bench.zc')
-rw-r--r--docs/history/15-o3/code/tests/bench.zc30
1 files changed, 0 insertions, 30 deletions
diff --git a/docs/history/15-o3/code/tests/bench.zc b/docs/history/15-o3/code/tests/bench.zc
deleted file mode 100644
index a7e53f5..0000000
--- a/docs/history/15-o3/code/tests/bench.zc
+++ /dev/null
@@ -1,30 +0,0 @@
-// four kernels with and without o3; bench.sh runs each one on each backend
-int csum(int lim) { int s = 0; for (int n = 1; n < lim; n++) { int x = n; while (x != 1) { if (x & 1) x = 3 * x + 1; else x = x / 2; s++; } } return s; }
-o3 int csum3(int lim) { int s = 0; for (int n = 1; n < lim; n++) { int x = n; while (x != 1) { if (x & 1) x = 3 * x + 1; else x = x / 2; s++; } } return s; }
-int sieve(fixed []int f) { int c = 0, n = len(f); for (int i = 0; i < n; i++) f[i] = 1; for (int i = 2; i < n; i++) if (f[i]) { c++; for (int j = i + i; j < n; j += i) f[j] = 0; } return c; }
-o3 int sieve3(fixed []int f) { int c = 0, n = len(f); for (int i = 0; i < n; i++) f[i] = 1; for (int i = 2; i < n; i++) if (f[i]) { c++; for (int j = i + i; j < n; j += i) f[j] = 0; } return c; }
-int digits(int n) { int s = 0; for (int i = 0; i < n; i++) { int x = i; while (x) { s = s + x % 10; x = x / 10; } } return s; }
-o3 int digits3(int n) { int s = 0; for (int i = 0; i < n; i++) { int x = i; while (x) { s = s + x % 10; x = x / 10; } } return s; }
-int fib(int n) { if (n < 2) return n; return fib(n - 1) + fib(n - 2); }
-o3 int fib3(int n) { if (n < 2) return n; return fib3(n - 1) + fib3(n - 2); }
-// input: a letter (the kernel; z runs none) and how many times to run it
-fn main()
-{
- fixed []int f = new(fixed []int, 50000);
- let which = getc(), reps = 0, ch = getc(), r = 0;
- while (ch >= '0' && ch <= '9') { reps = reps * 10 + ch - '0'; ch = getc(); }
- while (reps > 0) {
- if (which == 'a') r = csum(30000);
- if (which == 'b') r = csum3(30000);
- if (which == 'c') r = sieve(f);
- if (which == 'd') r = sieve3(f);
- if (which == 'e') r = digits(300000);
- if (which == 'f') r = digits3(300000);
- if (which == 'g') r = fib(22);
- if (which == 'h') r = fib3(22);
- reps--;
- }
- putn(r); putc(10);
- free(d*f);
- return 0;
-}