TKS Ephemeris · developer · performance

Performance Whitepaper & Swiss-Ephemeris Comparison

A reproducible benchmark of the TKS Ephemeris (JPL DE440) against the official Swiss Ephemeris C library, and an end-to-end profile of the Jyotiṣa page. Every figure below is reproducible from §5; measurements are best-of-three full runs on the machine in §1.

Headline. For the 11-body geocentric apparent-longitude workload (10,000 epochs), TKS is 1.31× faster than Swiss Ephemeris in file mode — 0.169 s vs 0.222 s — and the whole Jyotiṣa chart (25 computations) renders in a median 12.5 ms.

1 · Environment

CPUApple M3 Max — 14 cores (10 performance + 4 efficiency)
Memory36 GB unified · Model Mac15,10
OSmacOS 26.6.2 (Darwin 25.6.0, arm64 / T6031)
Toolchainrustc 1.98.0 · --release
TKS engineJPL DE440 (Chebyshev) · true Chitrāpakṣa
Swiss Ephemerispyswisseph 2.10.03 · real .se1 files (1800–2400), file mode (verified via returned flags, not the Moshier fallback)

2 · Ephemeris throughput — 10,000 × 11 = 110,000 positions

Bodies: Sun · Moon · Mercury · Venus · Mars · Jupiter · Saturn · Uranus · Neptune · Pluto · True-Node. Geocentric apparent tropical longitude, 1-day spacing.

EngineTotal (best-of-3)per 11-body setper positionvs Swiss
TKS Ephemeris (DE440)0.169 s0.0154 ms1.54 µs1.31× faster
Swiss Ephemeris 2.10.03 (files)0.222 s0.0202 ms2.02 µs1.00×
TKS per-call API¹0.267 s0.0243 ms2.43 µs1.20× slower
Swiss (Moshier fallback)1.260 s0.1146 ms11.45 µs—
¹ The public helper apparent_direction() fetches the Earth state per call; the production pipeline shares Earth/Sun per epoch and uses two light-time iterations — the TKS Ephemeris row. Target check: both engines deliver 10,000 × 11 positions well under 3 s. Correctness: true Rāhu = Gemini 10.78° in both (agree < 0.01°).

3 · Jyotiṣa page — end-to-end (25 computations)

The /tks-jyotish page issues 25 parallel computations (vara · chalit · 16 vargas · upagraha · Vimśottarī 3 levels · ṣaḍbala · aṣṭakavarga · maitrī · jaimini · doṣa · rāja/nābhasa-yoga · chara/nārāyaṇa/sudarśana dāśās · yoga-samuh · aṣṭottarī · gochara · kālacakra). Measured over 1,000 page loads (all 25 issued concurrently per load).

Metricminp50p90p99maxmeanthroughput
Full page (25 endpoints)10.65 ms12.45 ms13.3517.2124.6512.59 ms79.4 /s
Per-endpoint (warm): sudarśana 3.7 ms · dashas 6.3 ms · graha-sphuṭa 4.0 ms · ṣaḍbala 3.3 ms · bhāva-chalit 3.1 ms · divisionals 4.6 ms. A light endpoint (maitrī) measures 2.65 ms — the HTTP setup floor on this host.

4 · Concurrency

endpointreq/stime/req (concurrent)failed
sudarśana (ab -n 1000 -c 10)1,6460.607 ms0
maitrī2,3640.423 ms0

5 · Reproduction

# 1. Ephemeris, 10,000 x 11 (TKS)
cargo build --release --example bench_11 -p tks-ephemeris
./target/release/examples/bench_11

# 2. Swiss Ephemeris (real .se1 files), same 10,000 x 11
TKS_SWISS_EPHE=/path/to/ephe  /tmp/swevenv/bin/python scripts/bench_swiss.py

# 3. Full jyotisa page (25 endpoints, 1000 loads) + concurrency
./target/release/panchanga --serve --port 8099 &
python3 scripts/bench_page.py
ab -n 1000 -c 10 "http://127.0.0.1:8099/v1/vedic/sudarshana?engine=tks&date=2001-08-27&time=06:15&place=Dehradun&lat=30.3165&lon=78.0322&tz=5.5"

6 · Methodology

Warm-up: 30–50 iterations discarded; kernel pages and CPU caches resident.
Iterations: 10,000 × 11 for ephemeris; 1,000 for the page and concurrency.
Statistics: full latency distribution (min·p50·p90·p99·max·mean) for the page; best-of-three for the ephemeris micro-runs (variance < 3 %).
Fairness: identical bodies, epoch grid and iteration count; Swiss in file mode; the engine comparison counts the corrections each engine performs (light-time, aberration, solar deflection, true node).
Scope: server rows include HTTP/TCP setup (HTTP/1.0, Connection: close); ephemeris rows measure pure computation.
संस्करणः bin-1790843185