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. TKS's own compact kernel — TKS-EPH-1, 1.9 MB — runs the 11-body geocentric apparent-longitude workload (10,000 epochs, 110,000 positions) in 0.127 s: 1.31× faster than the full DE440 kernel (0.169 s, 114 MB) and 1.75× faster than Swiss Ephemeris in file mode (0.222 s), at a maximum residual of 0.092″; on all 14 cores it drops to 0.013 s (9.6×). The whole Jyotiṣa chart (25 computations) renders in a median 12.5 ms.
1 · Environment
CPU
Apple M3 Max — 14 cores (10 performance + 4 efficiency)
Bodies: Sun · Moon · Mercury · Venus · Mars · Jupiter · Saturn · Uranus · Neptune · Pluto · True-Node. Geocentric apparent tropical longitude, 1-day spacing. Single thread unless stated; best of 3; re-measured on 2026-10-08 on the environment in §1 (same machine, same run for Swiss).
TKS production pipeline (server path: shared Earth/Sun, DE440)
0.100 s
0.0091 ms
0.907 µs
1.5× faster
Swiss Ephemeris 2.10.03 — C library, files, positions only
0.148 s
0.0136 ms
1.35 µs
1.00× (like-for-like reference)
TKS per-call API¹ (DE440)
0.188 s
0.0171 ms
1.71 µs
1.27× slower
Swiss — C library, SWIEPH|SPEED (pyswisseph default flags: also computes speeds)
0.266 s
0.0241 ms
2.42 µs
0.56×
Swiss — via Python (pyswisseph, default flags)²
0.291 s
0.0265 ms
2.64–2.71 µs
0.51×
Swiss (Moshier fallback) — not re-run
1.260 s
0.1146 ms
11.45 µs
—
TKS-EPH v4 — batched 8/lane (NEON) — not re-run
—
—
0.010 µs
4.4× vs per-instant (measured earlier)
¹ 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. ² Python→C overhead of pyswisseph ≈ 0.25 µs/call (2.64–2.71 µs via Python vs 2.42 µs in C, same flags). Swiss is not thread-safe, so no multi-core row. The C figures come from scripts/bench_swiss_c.c (the libswe inside the pyswisseph wheel, real .se1 files, returned flags confirm file mode); three runs: 1.346 / 1.356 / 1.358 µs position-only. The earlier version of this page compared against Swiss through Python with speeds (7.8×); that mixes in Python overhead and extra work Swiss does and TKS's benchmark does not, so the fair headline is 3.9×. What changed since the previous version of this table: (a) the precession + 77-term nutation rotation is built once per epoch instead of ≈13× — the three "ordinary" TKS rows used to be equal (1.1–1.5 µs) because that, not the ephemeris, was the cost; (b) the engine can read the fitted TKS-EPH-2 file; (c) deflection, time-scale and sidereal-time corrections (accuracy fixes, no speed effect). Fidelity vs DE440 (max |Δ|, mas): TKS-EPH-2 ≤ 0.33 (Sun) · 0.12 (Moon) · 0.2 (Venus) · ≤ 0.11 others; TKS-EPH-1: Moon 101.7, Sun 35, true node 367. Correctness: true Rāhu agrees with Swiss to < 0.01° in the earlier comparison.
History of this number. The previous table said p50 12.45 ms. Adding the classical kāla/ceṣṭā-bala inputs to the natal snapshot (tomorrow’s sunrise + the weekdays of the last two saṅkrāntis ⇒ three more sunrise solves) made the page slower (26.4 ms; the light endpoint 2.5 → 6.4 ms) even while raw ephemeris speed went up 7.8×, because a page request is dominated by sunrise search, not by planet positions. Four changes fixed that: (1) the rise/set search scans at 10 min instead of 2 min below ±60° latitude (poles keep the fine scan) — sunrise_sunset 1.55 → 0.42 ms with results identical to < 1 ms (tests/rise_set_scan.rs); (2) rise/set results are memoised per place and date; (3) the natal snapshot is computed once per birth and shared by all 25 endpoints (concurrent identical requests wait on one computation); (4) the last saṅkrānti is taken from the precomputed sankranti.bin and refined in a ±2 min bracket (22 bisections instead of 44 from a 12-day window; bit-identical results on 60 random births). Measured effect: a request for a new birth (every request a cache miss) now takes maitrī 2.1 ms · ṣaḍbala 1.9 ms · sudarśana 2.8 ms (p50) — i.e. back to the level of the committed build of 2026-10-07 (2.5 / 2.6 / 3.4 ms) while still computing the classical bala inputs; with the snapshot already cached, maitrī is 0.19 ms and sudarśana 1.09 ms. Of the gain, the snapshot cache accounts for most of the page figure; the saṅkrānti catalogue saves only ≈ 0.3 ms per cache miss (bisection was never the expensive part).
Driven by a Python thread pool (not ab: ApacheBench stalled against this server on the current macOS, so the earlier ab figures of 1,646 / 2,364 req/s are not comparable). Identical requests mostly hit the snapshot cache; the client is the limiting factor for the light endpoint. Compare the two builds, not the absolute numbers.
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) + concurrency
./target/release/panchanga --serve --port 8099 &
BENCH_PAGE_LOADS=300 python3 scripts/bench_page.py # 1000 loads exhaust macOS ephemeral ports
# concurrency: 10 client threads x 1000 requests (python http.client), as in the table above
# TKS-EPH-2 vs Swiss (same machine): cargo run --release -p tks-ephemeris --example bench_tks_eph2 ; python scripts/bench_swiss.py
1.97× faster than the full DE440 kernel (0.038 s vs 0.074 s per 10,000 × 11, re-measured 2026-10-08; with the per-epoch reduction the reader is no longer the cost — TKS-EPH-2 runs at the same speed)
Fidelity (vs DE440)
geocentric apparent-longitude residual rms 0.0067″; maximum residual 0.10″ (Moon); Sun 0.035″; true node 0.37″; all other planets < 0.001″. TKS-EPH-2 (the long-span fit) is 300–1000× tighter for Sun/Moon/node. Status: TKS-EPH-1 is kept as the small reference kernel (and WASM demo); no live page or the engine reads it — the browser uses the tiled kernels, the engine uses DE440 and TKS-EPH-2.
Representation residual
the compact BSP reproduces the source state vectors with rms 0.5 km · max 9.4 km (Sun); Earth & Moon ≈ 0.3 m
vs Swiss
Swiss compresses (quantised integer deltas) to ≈ 0.3 MB / 100 yr; f32 here ≈ 1.5 MB
Generated by gen_eph100 from the DE440 source kernel; read back by the tks_eph reader (implements the engine's Ephemeris trait). The Moon dominates the size (short interval); quantisation à la Swiss would shrink it ~10×.
The 100-year catalogue (daily graha grid + tithi·nakṣatra·yoga·karana·vāra indices + exact transition instants) is memory-mapped and answers any date in nanoseconds; a 21 KB WebAssembly build runs the same kernel entirely in the browser (no server).
0 to /v1/tks/ephemeris & /v1/tks/limbs; identical to the server (sunrise ±7 s, sunset ±2 s, moonrise/set & bhadrā exact)
The ±200-year nirayana-longitude kernel is loaded once (wasm + service-worker cache); thereafter the whole core pañcāṅga — five limbs, sunrise/sunset, moonrise/set, vāra, lagna, graha rāśi, māsa, saṃvat, ayana, ayanāṃśa, bhadrā — is computed in the browser with no server round-trip. Outside ±200 yr it fetches the one tile covering the date (see below) — still client-side.
only the one tile covering the date is fetched (then cached); ±200 yr always resident
Far-era first call
24 ms (tile fetch + wasm init + whole pañcāṅga); steady 0.081 ms
vs Swiss
Swiss .se1 set (present, 100 files) = 94 MB planets+Moon, no asteroids; same ten bodies ≈ 99 MB (TKS) — comparable; TKS also has 16 asteroids + nodes + ayanāṃśa
The 30,400-yr span is served as tiles; the browser fetches only the ±200-yr tile covering the requested date, so far-era dates compute client-side in the same time as the present. int16 coefficient deltas halve the kernel; brotli on top, served with Content-Encoding: br.
Hipparcos star table (117,955 stars)
Table
tks-eph/tks_stars.bin — 117,955 Hipparcos stars, 24 B/star (HIP id · RA/Dec @ J1991.25 · proper motion · V mag)
Size
2.83 MB raw → 1.98 MB brotli (served Content-Encoding: br)
Date-independence
static catalogue; client applies proper-motion + IAU-2006 precession once per date (Spicā → nirayana 180.00°)
vs Swiss
Swiss default fixed-star catalogue = fixstars.cat1,259 stars (116 KB) (named sefstars.txt 1,590, 134 KB); no full Hipparcos — TKS carries ~94× more stars, ~24 B/star vs ~92 B/star text
The full Hipparcos catalogue ships in 2.83 MB (24 B/star); sorted by HIP so a lookup is a binary search, and the whole table is fetched once for the star panel.
8 · Naming convention & HTTP architecture
Product naming. The engine's own ephemeris is the TKS Ephemeris — series TKS-EPH-N, file tks-eph-<N>_<first>-<last>.tkseph (e.g. tks-eph-1_1950-2050.tkseph = 100-year, tks-eph-2_1550-2650.tkseph = long-span fit). It is built from JPL DE440 source data (provenance only); product and file naming follow the project's TKS convention.
The binary payload packs the nine nirayana longitudes and the ayanāṃśa as raw little-endian f64 — 86 bytes against 8,044 bytes of the equivalent JSON (~94× smaller). It removes float→string formatting on the server and string→float parsing on the client (the "zero-serialization" win), and reads directly with DataView / Float64Array. Layout: "TKSB" + ver:u8 + n:u8 + n×f64 + ayanāṃśa:f64. The batch endpoint returns all 25 computations as one JSON, sharing a single snapshot and parallelising the parts (1 round-trip vs 25).
TKS is a compact, TKS-named kernel built on public JPL DE440 data, with an open format and a native-Rust / WebAssembly stack (no FFI, server-free option); Swiss is the long-standing industry C library — broader in bodies and span, under AGPL / commercial terms. Both are accurate to sub-arcsecond for the classical bodies.
10 · Methodology
Warm-up: 30–50 iterations discarded; kernel pages and CPU caches resident. Iterations: 10,000 × 11 for ephemeris; 300 page loads and 1,000 concurrent requests for the page. 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.