#include <iostream>
#include <vector>
#include <chrono>
#include <cstring>

const int SIZE = 1024*1024;

void WithArray()
{
	using namespace std;
	char* a = new char[SIZE];
	auto b = &a[0];
	auto e = &a[SIZE];

	memset(a, 0, SIZE);
	int total=0;
	
	auto begin = chrono::system_clock::now();
	for(int c=0; c<100; c++) {
		for(auto p=b; p<e;) {
			total += *p++;
		}
	}
	auto end  = chrono::system_clock::now();
	cout << total << ":" << chrono::duration_cast<chrono::milliseconds>(end-begin).count() << endl;
	delete[] a;
}

void WithVector()
{
	using namespace std;
	vector<char> a(SIZE);
	auto b = a.begin();
	auto e = a.end();
	int total=0;
	
	auto begin = chrono::system_clock::now();
	for(int c=0; c<100; c++) {
		for(auto it=b; it<e;) {
			total += *it++;
		}
	}
	auto end  = chrono::system_clock::now();
	cout << total << ":" << chrono::duration_cast<chrono::milliseconds>(end-begin).count() << endl;
}

int main()
{
	WithArray();
	WithVector();
	WithArray();
	WithVector();
}
