
#include <stdio.h>
#include <stdlib.h>

#if defined(__GNUC__) && !defined(__MINGW32__)

#include <sys/types.h>
#include <sys/time.h>
int GetTickCount(void) {
  timeval t;
  gettimeofday( &t, 0 );
  return t.tv_sec*1000 + t.tv_usec/1000;
}

#else

//#ifndef _INC_WINDOWS
#ifndef _WINDOWS_
extern "C" __declspec(dllimport) unsigned __stdcall GetTickCount( void );
#endif
//#endif

#endif

char cmd[1<<16];

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

  if( argc<2 ) return 1;

  int i; char* p;
  for( i=1,p=cmd; i<argc; i++ ) p+=sprintf(p,"%s ",argv[i]);

  unsigned t = 0;

//printf( "!%s!\n", cmd );
  t = GetTickCount();
  system( cmd );
  t = GetTickCount() - t;

  FILE* log = fopen( "log.txt", "a+b" );
  if( log ) {
    fprintf(log, "%3i.%03is: %s\n",t/1000,t%1000, cmd );
    fclose(log);
  }

}
