#include <iostream>
#include <chrono>
#include <type_traits>
#include <stdlib.h>
#include <time.h> 

using namespace std;
using namespace std::chrono;

struct Test
{
  Test(int a, int b, int c) : a(a), b(b), c(c) { }
  int a, b, c;
};

const int NUMBER = 100000000;

int main()
{
  cout << "Creating " << NUMBER << " objects" << endl;

  high_resolution_clock::time_point start, end;
  start = high_resolution_clock::now();
  
  for(int i = 0; i < NUMBER; ++i)
  {
    Test *t = new Test(1, 2, 3);
    /* ... */
    delete t;
  }

  end = high_resolution_clock::now();
  auto duration = duration_cast<milliseconds>(end - start).count();
  cout << "Normal: " << duration << "ms" << endl;


  start = high_resolution_clock::now();

  std::aligned_storage<sizeof(Test), alignof(Test)>::type als[1];
  for(int i = 0; i < NUMBER; ++i)
  {
    Test *t = new(als) Test(1, 2, 3);
    /* ... */
    t->~Test();
  }

  end = high_resolution_clock::now();
  duration = duration_cast<milliseconds>(end - start).count();
  cout << "Placement: " << duration << "ms" << endl;

  return 0;
}