Step 1
Set up a performance test which exercises the move assignment operator.
Set up another performance test which exercises the copy assignment operator.
Step 2
Set up the assignment operator both ways as instructed in the problem statement.
Step 3
Iterate on Steps 1 and 2 until you have confidence that you did them correctly.
Step 3 should help educate you as to what is going on, most likely by telling you where the performance is changing and where it is not changing.
Guessing is not an option for Steps 1-3. You actually have to do them. Otherwise you will (rightly) have no confidence that your guesses are correct.
Step 4
Now you can start guessing. Some people will call this "forming a hypothesis." Fancy way of saying "guessing." But at least now it is educated guessing.
I ran through this exercise while answering this question and noted no significant performance difference on one test, and a 6X performance difference on the other. This further led me to an hypothesis. After you do this work, if you are unsure of your hypothesis, update your question with your code, results, and subsequent questions.
Clarification
There are two special member assignment operators which typically have the signatures:
HasPtr& operator=(const HasPtr& rhs); // copy assignment operator
HasPtr& operator=(HasPtr&& rhs); // move assignment operator
It is possible to implement both move assignment and copy assignment with a single assignment operator with what is called the copy/swap idiom:
HasPtr& operator=(HasPtr rhs);
This single assignment operator can not be overloaded with the first set.
Is it better to implement two assignment operators (copy and move), or just one, using the copy/swap idiom? This is what Exercise 13.53 is asking. To answer, you must try both ways, and measure both copy assignment and move assignment. And smart, well meaning people get this wrong by guessing, instead of testing/measuring. You have picked a good exercise to study.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…