#include <iostream>
#include <algorithm>
#include <cstring>
#include <ctime>
#define DIM 256
#define LIMIT 1000000
using namespace std;
class Vector
{
private:
const int size;
int *array;
public:
Vector(const int new_size) : size(new_size), array(new int [new_size]) {}
// copy constructor
Vector(const Vector &rhs) : size(rhs.size)
{
// deep copy is required
array = new int [rhs.size];
memcpy(array, rhs.array, rhs.size * sizeof(int));
}
int& operator[] (const int index)
{
return array[index];
}
int operator[] (const int index) const
{
return array[index];
}
Vector& operator+= (const Vector &rhs)
{
for(int index=0; index<size; ++index)
array[index] += rhs[index];
return *this;
}
Vector operator+ (const Vector &rhs) const
{
Vector temp(*this);
temp += rhs;
return temp;
}
~Vector() { delete [] array; }
};
double runtime_without_move_semantic (const int iterative_limit)
{
clock_t begin, end;
Vector a(DIM), b(DIM), c(DIM);
for(int i=0; i<DIM; ++i) {
a[i] = 0;
b[i] = 1;
c[i] = 2;
}
begin = clock();
for (int iter; iter<iterative_limit; ++iter) {
Vector d = a+b+c;
d[iter&DIM] = 2;
}
end = clock();
return (static_cast<double>(end-begin) / static_cast<double>(CLOCKS_PER_SEC) );
}
int main()
{
cout << runtime_without_move_semantic(LIMIT) << '\n';
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPGN0aW1lPgojZGVmaW5lIERJTSAyNTYKI2RlZmluZSBMSU1JVCAxMDAwMDAwCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgVmVjdG9yCnsKcHJpdmF0ZToKICBjb25zdCBpbnQgc2l6ZTsKICAgIGludCAqYXJyYXk7CgpwdWJsaWM6CglWZWN0b3IoY29uc3QgaW50IG5ld19zaXplKSA6IHNpemUobmV3X3NpemUpLCBhcnJheShuZXcgaW50IFtuZXdfc2l6ZV0pIHt9CgkKCS8vIGNvcHkgY29uc3RydWN0b3IKCVZlY3Rvcihjb25zdCBWZWN0b3IgJnJocykgO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