Menu

1 / 2

Keeping the slow version as a test oracle

DEV Community: rust·Darkø Tasevski·about 8 hours ago
#gksNPkTF
#devtorust#devto#dev#disclosure#test
Long article (2504 words) — no AI summary yet.
Reading 0:00
15s threshold

When a piece of code that is slow but obviously right has to become fast, one thing that is easy to skip is keeping the slow version around, in the tests, and checking the fast one against it over a lot of generated inputs. I did that recently in the Rust importer of the reading app I'm building on the side, where it threw out two fast versions that looked fine on paper before a third one agreed with it, and then a wider generator found a case where even the third one doesn't agree, so these are my notes on how the comparison was set up and on what "they agree" ended up meaning.

The transform

The pass in question is the same one I wrote about in Bounding a Rust cost test by the parser's own time , which ends <details> elements the source never closes, so here we only need the short version.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.