#include <sys/time.h>
#include <fcntl.h>
#include <iostream>
#include <memory>

using namespace std;
#include <Msgs.hh>

int
main()
{
  list<int> lst;
  for (int j = 1; j <= 20000; ++j) {
    lst.push_back(j*3);  
  }

  int fd = open("eeout", O_WRONLY);
  if (fd < 0) {
    cout << "open failed." << "\n";
    return 0;
  }

  auto_ptr<Buffer> buf(new Buffer(8192));
  buf->sock_ = fd;

  timeval before_tv, after_tv;
  struct timezone tz;
  Msgs msgs;

  gettimeofday(&before_tv, &tz);
  msgs.Send(buf.get(), lst); 
  gettimeofday(&after_tv, &tz);
  if (before_tv.tv_sec != after_tv.tv_sec) {
    after_tv.tv_usec += 1000000;
  }

  long diff = after_tv.tv_usec - before_tv.tv_usec;
  cout << "That took (microseconds) " << diff << endl;
  close(fd);
  return 1;
}