# Optimising \`assert\_eq\` & \`assert\_ne\`

**URL:** <https://internals.rust-lang.org/t/optimising-assert-eq-assert-ne/24739>\
**Category:** libs\
**Created:** [October 31, 2026, 11:33pm UTC](https://internals.rust-lang.org/t/optimising-assert-eq-assert-ne/24739 "2026-10-31T23:33:51Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![Dwarsloeper](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/dwarsloeper/32/11073_2.png) [@Dwarsloeper](https://internals.rust-lang.org/u/Dwarsloeper)\
**Post date:** [November 7, 2026, 8:19am UTC](https://internals.rust-lang.org/t/optimising-assert-eq-assert-ne/24739/9 "2026-11-07T08:19:03Z")

</div>

Instead of one humungous function of 1000 macros, I split this up into 25 more natural functions of 40 macros each. Each function has a very different order, so that they don’t get unified before compilation. [Godbolt](https://godbolt.org/z/jrn8fqcsK)

To be on the safe side (avoiding any daemon perturbing one run,) I ran these series of 8x100, 10 times. The results are still mixed, but only **ever so lightly.**

| ϕ&nbsp;seconds | w/o worst&nbsp;3 | w/o best 3  
& worst 3 | all 1000 | best | 4th best |
| --- | --- | --- | --- | --- | --- |
| \_msg\_old | 0.411702 | 0.412044 | 0.412640 | 0.293130 | 0.304502 |
| \_msg | 0.418178 | 0.418548 | 0.419028 | 0.293763 | 0.299631 |
| Δ | **+0.016%** | **+0.016%** | **+0.015%** | **+0.002%** | **-0.016%** |
| \_old | 0.208479 | 0.208700 | 0.208967 | 0.134058 | 0.136964 |
| \_ | 0.201564 | 0.201759 | 0.202058 | 0.136308 | 0.137547 |
| Δ | **-0.033%** | **-0.033%** | **-0.033%** | **+0.017%** | **+0.004%** |
| -O\_msg\_old | 0.817969 | 0.818573 | 0.819841 | 0.616232 | 0.622958 |
| -O\_msg | 0.834081 | 0.834737 | 0.835399 | 0.611030 | 0.629091 |
| Δ | **+0.020%** | **+0.020%** | **+0.019%** | **-0.008%** | **+0.010%** |
| -O\_old | 0.452906 | 0.453276 | 0.453830 | 0.326032 | 0.334296 |
| -O | 0.458596 | 0.459001 | 0.459529 | 0.320346 | 0.333360 |
| Δ | **+0.013%** | **+0.013%** | **+0.013%** | **-0.017%** | **-0.003%** |

---

_[View the full topic](https://internals.rust-lang.org/t/optimising-assert-eq-assert-ne/24739)._
