
// load a file into memory
#include <iostream>
#include <fstream>
#include <time.h>

using namespace std;

int main(int argc, char* argv[]) {

//  int length;
  char * buffer;

  ifstream is;
  is.open (argv[1], ios::binary );

/*
  // get length of file:
  is.seekg (0, ios::end);
  length = is.tellg();
  is.seekg (0, ios::beg);
*/

/*
  // read data as a block:
  is.read (buffer,length);
*/

  int i = 0;
  int j = 0;
  double x;

  time_t start=0,end=0;
  double dif;
  int exps = 200;
  int probes = 10000;

  // allocate memory:
  buffer = new char [sizeof(x)];

  start = time(NULL);
  for (j=0;j<probes;j++)
  {
	  for (i=0;i<exps;i++)
	  {
//		x = rand();
		is.seekg(sizeof(x) * (probes*i + j));
		is.read(buffer, sizeof(x));
	  }
  }
  end = time(NULL);

  dif = difftime(end, start);
  cout << "read column wise completed in " << dif << " seconds\n";

  is.close();

  return 0;
}


