sourceextensions/clock/demos/bridge-cost.xtl
1⍝# What the text bridge costs (docs/bridge.md): calls per second, and
2⍝# Floats per second carried out and back (it uses hello too).
3⍝# Run: just demo clock bridge-cost
4
5ᶜᵏ⁼u̲se< "Clock"
6ʰˣ⁼u̲se< "Hello"
7
8⍝# 200 calls of hello's answer: each is a get across the channel
9n ← 200
10ms ← '{ k → '{ i → ʰˣa̲nswer @ } e̲ach r̲ange k } ᶜᵏt̲ime n
11"calls per second:"
12f̲loor (1000.0 × f̲loat n) ÷ ms m̲ax 0.001
13
14⍝# a 100,000-element Float array out to Rust and back (echo)
15v ← 0.5 + f̲loat r̲ange 100000
16ms ← 'ʰˣe̲cho ᶜᵏt̲ime v
17"Floats per second, out and back:"
18f̲loor (1000.0 × 100000.0) ÷ ms m̲ax 0.001
19
20⍝ the same sum in X_eTaL and in Rust
21"sum in X_eTaL (ms), in Rust over the bridge (ms):"
22('{ x → '+ r̲/ x } ᶜᵏt̲ime v) m̲ax 0.0
23('ʰˣs̲um ᶜᵏt̲ime v) m̲ax 0.0