Performance
Every port is benchmarked on the same eight operations and the same 64 dates, defined once in the
hub’s spec/BENCHMARK.md. Each
port also measures every other Bikram Sambat library it could find in its language, on the same
machine and the same dates.
In all seven languages, every port is faster than all 33 other libraries on both conversions. None of those libraries gives the same answer as the hub’s data on all 64 dates; each report lists where they differ.
Against other libraries
Section titled “Against other libraries”BS to AD (B1), time per call. “Next fastest” is the fastest other library in that language.
| Language | NepDate | Next fastest | Its time | Measured |
|---|---|---|---|---|
| Rust benchmark report | 2.9 ns | nepdate-cli | 61 ns | 4 |
| C++ benchmark report | 7.1 ns | nepdate-cli | 33 ns | 3 |
| Go benchmark report | 6.2 ns | go-nepali | 173 ns | 4 |
| Swift benchmark report | 21 ns | Nepali-Date-Picker-SPM | 922 ns | 2 |
| Kotlin benchmark report | 21 ns | adbs | 403 ns | 3 |
| TypeScript benchmark report | 31 ns | nepali-datetime | 380 ns | 9 |
| Python benchmark report | 724 ns | bikram-sambat | 1.24 µs | 8 |
“Measured” counts the other libraries timed in that language. Each language’s report, linked from its name, has AD to BS (B2) too, every library’s row, which dates each one disagrees on, and why.
Every operation
Section titled “Every operation”Time per call for B1 to B8. Lower is better. B8 builds a whole month grid with tithi and holidays, 29 to 32 days.
- B1 BS to AD
- B2 AD to BS
- B3 Add 1000 days
- B4 Add 13 months
- B5 Long Nepali date with weekday
- B6 Strict parse
- B7 Patro info for a day
- B8 Patro month grid
| Language | B1 | B2 | B3 | B4 | B5 | B6 | B7 | B8 |
|---|---|---|---|---|---|---|---|---|
| Rust | 2.9 ns | 3.1 ns | 3.2 ns | 2.6 ns | 16 ns | 18 ns | 3.5 ns | 299 ns |
| C++ | 7.1 ns | 8.9 ns | 7.5 ns | 5.6 ns | 28 ns | 12 ns | 13 ns | 517 ns |
| Go | 6.2 ns | 5.0 ns | 4.7 ns | 4.1 ns | 31 ns | 35 ns | 12 ns | 398 ns |
| Swift | 21 ns | 20 ns | 14 ns | 14 ns | 391 ns | 53 ns | 40 ns | 1.53 µs |
| Kotlin | 21 ns | 12 ns | 15 ns | 13 ns | 192 ns | 39 ns | 4.5 ns | 135 ns |
| TypeScript | 31 ns | 27 ns | 51 ns | 56 ns | 175 ns | 66 ns | 5.6 ns | 517 ns |
| Python | 724 ns | 822 ns | 662 ns | 598 ns | 527 ns | 1.32 µs | 128 ns | 21.6 µs |
| C# NepDate | 13 ns | 19 ns | 18 ns | 19 ns | 153 ns | 22 ns | 48 ns | 3.13 µs |
C# NepDate 2.0.7 on .NET 10 is the reference (its report). The conversions, arithmetic and patro lookups allocate nothing in Rust, C++, Go and Swift.
Reading the numbers
Section titled “Reading the numbers”- Compare within a row of the first table, not across languages. Each language was measured on its own runtime, and Swift on GitHub’s macOS runner (Apple M1), not the laptop the others used (Intel Core i5-12500H).
- Some runs were not on a quiet machine. Each report records the CPU load during its run; the stable release repeats them on an idle machine, pinned to one core, as the spec asks.
- Speed is not the reason to pick a date library; correct dates are. Every port is checked against the same 20,360 golden rows and 7,176 month boundaries first (Same answer everywhere), and the benchmarks run only after that.
The method, the 64 dates and the rules for timing are in
spec/BENCHMARK.md.