Good evening fellow coders, I'm a newbie in C++ and after searching for an answer I have not come to find a helpful answer. I'm testing #pragma pack right now and want to compare access speeds with unaligned memory, therefore I have a few structs I want to test elapsed time with.
struct ReallySlowStruct {
char c : 6;
__int64 d : 64;
int b : 32;
char a : 8;
};
And
int main() {
struct ReallySlowStruct s;
std::chrono::steady_clock::time_point begin = std::chrono::high_resolution_clock::now();
s.a = 'c';
s.d = 100;
s.b = 50;
s.a = 'a';
std::chrono::steady_clock::time_point end = std::chrono::high_resolution_clock::now();
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() << std::endl;
system("pause");
return 0;
}
This is what I found how to measure elapsed time with using the Chrono library. However, the output is always 0 and I don't know why. I've tried the different clocks, as well as different time units, but it's always zero. Can anyone explain what's wrong with it? I'm using VS 2013.