How it works...
This recipe is set up like a large benchmark or testing scheme: in Step 1, we define the functions to be tested, each with different input parameters, but the same behavior; it fills Vec up to a minimum sum. These parameters reflect different ways of sharing ownership, including RefCell, Cell, and Cow.
Steps 2 and 3 create tests that work exclusively on the different ways adopted by RefCell and Cell of handling and failing these values. Step 5 does something similar to the Cow type; all are great opportunities to test out your own theories as well!
In Steps 4 and 6, we are creating and running benchmarks and tests on the functions we created in this recipe. The results are surprising. In fact, we tried different computers ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access