#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
#define ITER 1000000
struct foo1 {
__int64 start, end, freq;
HANDLE hprocess;
DWORD oldclass;
foo1() : hprocess(GetCurrentProcess()), oldclass(GetPriorityClass(hprocess)) {
Sleep(10);
// SetPriorityClass(hprocess, REALTIME_PRIORITY_CLASS);
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
QueryPerformanceCounter((LARGE_INTEGER*)&start);
}
~foo1() {
QueryPerformanceCounter((LARGE_INTEGER*)&end);
// SetPriorityClass(hprocess, oldclass);
std::cout << (int)(end - start) << std::endl;
}
};
struct person {
int age;
string name;
person(int age, const string& name) : age(age), name(name) {}
};
void foo(const person&& x)
{
// cout << "rvalue : " << x.age << "," << x.name << endl;
}
void foo(const person& x)
{
// cout << "lvalue : " << x.age << "," << x.name << endl;
}
int main()
{
{
foo1 f;
for (int i = 0; i < ITER; i++)
foo(person(22, "Akira")); // rvalue : 22,akira
}
person johnny(38, "Johnny");
{
foo1 f;
for (int i = 0; i < ITER; i++)
foo(johnny); // lvalue : 38,Johnny
}
}