#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <vector>

class stopwatch
{
	clock_t last_;
public:
	stopwatch()
	{
		reset();
	}
	void reset()
	{
		last_ = std::clock();
	}
	double time()
	{
		return (std::clock() - last_) / static_cast<double>(CLOCKS_PER_SEC);
	}
};

void my_copy(void* dst, const void* src, std::size_t size)
{
  std::size_t pack_size = size / sizeof(long long);
  std::size_t leftover_size = size - pack_size * sizeof(long long);

  while (pack_size--)
		*(long long*)dst = *(long long*)src;

  while (leftover_size--)
		*(char*)dst = *(char*)src;
}

int main()
{
	std::vector<char> source(52428800), destination(52428800);
	std::generate(source.begin(), source.end(), rand);
	
	{
		stopwatch w;
		for (int i = 10; i--; )
			std::copy(source.begin(), source.end(), destination.begin());
		std::cout << "copy time: " << w.time() << '\n';
	}

	{
		stopwatch w;
		for (int i = 10; i--; )
			std::memcpy(destination.data(), source.data(), source.size());
		std::cout << "memcpy time: " << w.time() << '\n';
	}

	{
		stopwatch w;
		for (int i = 10; i--; )
			my_copy(destination.data(), source.data(), source.size());
		std::cout << "my_copy time: " << w.time() << '\n';
	}
}