#include "charm++.h"
#include <stdlib.h>

#include "main.h"

CkChareID mainhandle;

extern "C" {
#include "simplemsg.h"
};

main::main(CkArgMsg *m)
{
  CkPrintf("Main chare created\n");
  // create Test chare
  Msg *msg = new Msg;
  msg->data = 0;
  CProxy_Testcharm::ckNew(msg, 0);
  starttests = CkTimer();
  mainhandle = thishandle;
}

void main::testend(Msg *msg)
{
  double endtests = CkTimer();
  int i;
  if(msg->data==1) {
    CProxy_Testsdag::ckNew(msg, 0);
    CkPrintf("Charm++ test took %lf seconds\n", (endtests-starttests));
    starttests = CkTimer();
  } else if(msg->data==2) {
    CProxy_Testthreads::ckNew(msg, 0);
    CkPrintf("Sdag++ test took %lf seconds\n", (endtests-starttests));
    starttests = CkTimer();
  } else {
    CkPrintf("Threads test took %lf seconds\n", (endtests-starttests));
    delete msg;
    CkExit();
  }
}

#include "main.def.h"
