Appendix B. Test Results for Single-Threaded versus Multithread-Safe String Implementations

This appendix contains supplementary details for Item 16 and Appendix A. The test harness source code can be downloaded via a link on this book's Web page at http://www.gotw.ca/publications/mxc++.htm, if you'd like to try it on your system.

Approach

To assess COW, I performed measurements of three kinds of functions:

  1. Copying (where COW shines, its raison d'être)

  2. Mutating operations that could trigger reallocation (represented by Append(), which gradually lengthens; this is to make sure any conclusions drawn can take into account periodic reallocation overhead due to normal string use)

  3. Possibly-mutating operations that do not change length enough to trigger reallocation, ...

Get More Exceptional C++ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.