Guest User

Untitled

a guest
May 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. template<class T>
  2. void Foo2(T&& a) {
  3. string b = std::forward<T>(a);
  4. };
  5.  
  6. template<class T>
  7. void Foo3(T&& a) {
  8. string b = a;
  9. };
  10.  
  11. const int tryes = 1'000'000;
  12. for (int i = 0; i < 5; i++) {
  13. {
  14. muTimer T1;
  15. T1.start();
  16. for (int i = 0; i < tryes; i++) {
  17. Foo3(std::move("Habrahabr"));
  18. }
  19. cout << T1.stop().duration() << endl;;
  20. }
  21. {
  22. muTimer T1;
  23. T1.start();
  24. for (int i = 0; i < tryes; i++) {
  25. Foo2(std::move("Habrahabr"));
  26. }
  27. cout << T1.stop().duration() << endl;;
  28. }
  29. {
  30. muTimer T1;
  31. T1.start();
  32. for (int i = 0; i < tryes; i++) {
  33. Foo3(std::move("Habrahabr"));
  34. }
  35. cout << T1.stop().duration() << endl;;
  36. }
  37. {
  38. muTimer T1;
  39. T1.start();
  40. for (int i = 0; i < tryes; i++) {
  41. Foo2(std::move("Habrahabr"));
  42. }
  43. cout << T1.stop().duration() << endl;;
  44. }
  45. }
  46.  
  47. call ??$forward@AEAV?$basic_string@DU?$char_trait...........
  48.  
  49. ??$forward@AEAV?$basic_string@DU..... PROC
  50. mov QWORD PTR [rsp+8], rcx
  51. mov rax, QWORD PTR _Arg$[rsp]
  52. ret 0
Add Comment
Please, Sign In to add comment