Back to index

texmacs  1.0.7.15
Defines | Typedefs | Functions
timer.hpp File Reference
#include "string.hpp"
#include "tm_configure.hpp"
#include <sys/timeb.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define HAVE_TIME_T

Typedefs

typedef long time_t

Functions

time_t raw_time ()
time_t texmacs_time ()
void bench_start (string task)
void bench_cumul (string task)
void bench_end (string task)
void bench_reset (string task)
void bench_print (string task)
void bench_print ()

Define Documentation

#define HAVE_TIME_T

Definition at line 18 of file timer.hpp.


Typedef Documentation

typedef long time_t

Definition at line 19 of file timer.hpp.


Function Documentation

void bench_cumul ( string  task)

Definition at line 69 of file timer.cpp.

                          {
  // end timer for a given type of task, but don't reset timer
  timing_level (task) --;
  if (timing_level [task] == 0) {
    int ms= ((int) texmacs_time ()) - timing_last (task);
    timing_nr    (task) ++;
    timing_cumul (task) += ms;
    timing_last -> reset (task);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bench_end ( string  task)

Definition at line 81 of file timer.cpp.

                        {
  // end timer for a given type of task, print result and reset timer
  bench_cumul (task);
  bench_print (task);
  bench_reset (task);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bench_print ( string  task)

Definition at line 98 of file timer.cpp.

                          {
  // print timing for a given type of task
  if (DEBUG_BENCH) {
    int nr= timing_nr [task];
    cout << "Timing ] Task '" << task
        << "' took " << timing_cumul [task] << " ms";
    if (nr > 1) cout << " (" << nr << " invocations)";
    cout << "\n";
  }
}

Here is the caller graph for this function:

void bench_print ( )

Definition at line 120 of file timer.cpp.

               {
  // print timings for all types of tasks
  array<string> a= collect (timing_cumul);
  int i, n= N(a);
  for (i=0; i<n; i++)
    bench_print (a[i]);
}

Here is the call graph for this function:

void bench_reset ( string  task)

Definition at line 89 of file timer.cpp.

                          {
  // reset timer for a given type of task
  timing_level->reset (task);
  timing_nr   ->reset (task);
  timing_cumul->reset (task);
  timing_last ->reset (task);
}

Here is the caller graph for this function:

void bench_start ( string  task)

Definition at line 61 of file timer.cpp.

                          {
  // start timer for a given type of task
  if (timing_level [task] == 0)
    timing_last (task)= (int) texmacs_time ();
  timing_level (task) ++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 29 of file timer.cpp.

            {
#ifdef HAVE_GETTIMEOFDAY
  struct timeval tp;
  gettimeofday (&tp, NULL);
  return (time_t) ((tp.tv_sec * 1000) + (tp.tv_usec / 1000));
#else
  timeb tb;
  ftime (&tb);
  return (time_t) ((tb.time * 1000) + tb.millitm);
#endif
}

Here is the caller graph for this function:

Definition at line 44 of file timer.cpp.

                {
#ifdef HAVE_GETTIMEOFDAY
  struct timeval tp;
  gettimeofday (&tp, NULL);
  return ((time_t) ((tp.tv_sec * 1000) + (tp.tv_usec / 1000))) - start_time;
#else
  timeb tb;
  ftime (&tb);
  return ((time_t) ((tb.time * 1000) + tb.millitm)) - start_time;
#endif
}