Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<class T>
- void Foo2(T&& a) {
- string b = std::forward<T>(a);
- };
- template<class T>
- void Foo3(T&& a) {
- string b = a;
- };
- const int tryes = 1'000'000;
- for (int i = 0; i < 5; i++) {
- {
- muTimer T1;
- T1.start();
- for (int i = 0; i < tryes; i++) {
- Foo3(std::move("Habrahabr"));
- }
- cout << T1.stop().duration() << endl;;
- }
- {
- muTimer T1;
- T1.start();
- for (int i = 0; i < tryes; i++) {
- Foo2(std::move("Habrahabr"));
- }
- cout << T1.stop().duration() << endl;;
- }
- {
- muTimer T1;
- T1.start();
- for (int i = 0; i < tryes; i++) {
- Foo3(std::move("Habrahabr"));
- }
- cout << T1.stop().duration() << endl;;
- }
- {
- muTimer T1;
- T1.start();
- for (int i = 0; i < tryes; i++) {
- Foo2(std::move("Habrahabr"));
- }
- cout << T1.stop().duration() << endl;;
- }
- }
- call ??$forward@AEAV?$basic_string@DU?$char_trait...........
- ??$forward@AEAV?$basic_string@DU..... PROC
- mov QWORD PTR [rsp+8], rcx
- mov rax, QWORD PTR _Arg$[rsp]
- ret 0
Add Comment
Please, Sign In to add comment