omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / bench / omc_efficiency / kernels / leafcall.om
| 1 | note leafcall: a two-parameter leaf function called 30000000 times from a loop that keeps values |
| 2 | note live across the call; s = 1 + sum mix(i, 2654435761), t = xor of every running s. Prints s then t. |
| 3 | note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without |
| 4 | note start-up and output) as one decimal line on stderr; stdout is unchanged. |
| 5 | global out uchar 32 |
| 6 | fn putnum fd int v ulong to void |
| 7 | put out 31 10 |
| 8 | p = ulong 31 |
| 9 | x = v |
| 10 | while gt x 9 |
| 11 | p = sub p 1 |
| 12 | put out p uchar add rem x 10 48 |
| 13 | x = div x 10 |
| 14 | end |
| 15 | p = sub p 1 |
| 16 | put out p uchar add x 48 |
| 17 | w = write fd out p sub 32 p |
| 18 | end |
| 19 | fn mix x ulong k ulong to ulong |
| 20 | ret xor mul x k shr x 5 |
| 21 | end |
| 22 | fn main to int |
| 23 | t0 = monons |
| 24 | s = ulong 1 |
| 25 | t = ulong 0 |
| 26 | for i ulong 30000000 |
| 27 | s = add s mix i 2654435761 |
| 28 | t = xor t s |
| 29 | end |
| 30 | t1 = monons |
| 31 | putnum 2 ulong sub t1 t0 |
| 32 | putnum 1 s |
| 33 | putnum 1 t |
| 34 | ret 0 |
| 35 | end |