timer

Accession:50185
return amount of processor time used by a hoc call<br> only tested under LINUX (other UNIX systems may require changing #include -- see 'man clock') <br> // time("job()") will return processor time required to run job<br> // if tmstr is set then time() will run job listed there (default "run()")<br> // prints out date before and after as well as processor time so can assess loading<br> // if CPU is unloaded real elapsed time should equal processor time<br>
Tool Information (Click on a link to find other Tools with that property)
Tool Type: Utility;
Simulation Environment: NEURON;
\
timer
README
prtime.mod
time.hoc
                            
: $Id: prtime.mod,v 1.3 2005/03/25 13:22:54 billl Exp $

NEURON {
    SUFFIX nothing
}

VERBATIM
#include <time.h>
#include <limits.h>
ENDVERBATIM

:* PROCEDURE prtime ()
FUNCTION prtime () {
VERBATIM
  double prt;
  static double PRTIME;
  prt = (clock()-PRTIME)/CLOCKS_PER_SEC;
  // UINT_MAX for 32 bit machine -- see 'man clock'
  if (prt<0) prt += UINT_MAX/CLOCKS_PER_SEC; 
  PRTIME=clock();
  _lprtime = prt;
ENDVERBATIM
}

FUNCTION now () {
VERBATIM
  _lnow = time((time_t*)0);
  _lnow -= (12784) * 24*60*60; // time from the Epoch to 01/01/05
ENDVERBATIM
}

:* PROCEDURE sleepfor ()
PROCEDURE sleepfor (sec) {
VERBATIM
  struct timespec ts;
  ts.tv_sec = (time_t)_lsec;
  ts.tv_nsec = (long)0;
  nanosleep(&ts,(struct timespec*)0);
ENDVERBATIM
}