diff_bench
This manual documents version 0.1.0 of Luna-Flow/diff_bench as it stands on
the current branch.
Overview
diff_bench holds differential correctness and performance benchmarks for
Luna-Flow MoonBit packages. Each benchmark runs two decimal libraries on the
same inputs, checks both against an independent BigInt oracle, and measures
them with Mare Mark only where the
results are right. The subject on the Luna-Flow side is
floating’s decimal_gda package.
Every input is materialized from a fixed seed into a neutral decimal , converted to each library outside timing, and computed at a precision that provably holds the exact result. Results are canonicalized and compared with the oracle by exact equality. Timed samples of the two libraries are paired by dataset, repetition and block, and summarized by medians.
Install
The repository is a GitHub-only reference project. It is not published on
mooncakes and is not meant as a runtime dependency, so there is no
moon add step. Clone it and work inside the module:
git clone https://github.com/Luna-Flow/diff_bench.git
cd diff_bench
moon test --target native
A package inside the module imports a benchmark in its moon.pkg:
import {
"Luna-Flow/diff_bench/dzmingli_vs_floating",
}
The code needs the MoonBit toolchain 0.10.20 or later (moonc ≥ 0.10.20) with the
moon.mod and moon.pkg manifests. The library packages build on every
target; the executables and the asynchronous Mare Mark runs need native
(the async runner also works on js). Published measurements are native
release runs.
Pages
The module has seven packages: the root package, documented as core, two
benchmark libraries and one scaling and one common-digit executable for each.
| Part | Tutorial | API | Design |
|---|---|---|---|
core: the root package, a template placeholder | tutorial | API | design |
dzmingli_vs_floating: moonbit-community/decimal@0.1.0 versus floating GDA, exact oracle, 19 operations | tutorial | API | design |
dzmingli_vs_floating/bench: scaling executable, 1 to 20,000 digits | tutorial | API | design |
dzmingli_vs_floating/bench_common: common-digit executable, 1 to 28 digits | tutorial | API | design |
floating_vs_decmial_x: moonbitlang/x/decimal versus floating GDA, two semantic groups | tutorial | API | design |
floating_vs_decmial_x/bench: scaling executable, 1 to 4,096 digits | tutorial | API | design |
floating_vs_decmial_x/bench_common: common-digit executable, 1 to 28 digits | tutorial | API | design |
The performance chapter reports the measured results of both comparisons: DzmingLi versus GDA and X versus GDA. The contribution guidelines cover style, tests and the documentation workflow.
Exported items
Both benchmark libraries export the same skeleton, with library-specific adapters:
- Neutral decimal model:
DecimalValue,parse_decimal_value,normalize,canonical_string, and exactadd,subtract,multiply,compare - Oracle:
oracle_operation(andoracle_operation3for FMA),oracle_divide,oracle_multiply,OracleResult - Cases and fixtures:
Operation,generate_decimal,generate_cases,working_precision,prepare_fixture,run_gdaandrun_dzorrun_x,canonical_observation - Mare Mark integration:
run_mare_benchmark,default_benchmark_protocol,smoke_protocol,expand_digit_scales,PerformanceResultand the report writersmare_performance_report_htmlandmare_performance_report_document
Artifacts and tools
Raw JSONL records, HTML reports, Plot IR and the PNG, PDF and SVG figures are
kept under artifacts/<package>/, outside the manual. The tools/ directory
holds the Python figure layouts (plot_dzmingli_benchmark.py,
plot_dzmingli_supplementary_benchmark.py, layout_x_decimal.py, sharing
mare_plot_ir.py) and the official decTest audit
(run_dzmingli_dectest_audit.sh).
Where to read next
- New to the package: read the
dzmingli_vs_floatingtutorial. It checks one division against the oracle in a dozen lines and then reproduces the published run. - Reading the results: start with the performance pages, then the design pages for what the numbers mean: the precision contract, the paired statistics and the semantic groups of the X comparison.
- Contributing: read both design pages, then the contribution guidelines. A new operation needs an oracle rule, a precision bound with a proof, and a test before it is timed.
Validation
Run the release checks from the repository root:
moon check --target all
moon test --target native