Exemple #1
0
/**
  * Gets initial reference point to measure time from (I assume that MPI_Wtime can be skewed).
  */
void profiler_init(const char *name)
{
    profFile = fopen(name, "wt");	// Opens output file.
    if(!profFile) error("profiler_init: cannot open output file stream.");

    time_get(&profStartTime);
    double res, acc;
    res = time_resolution(&acc);
    fprintf(profFile, "Accuracy of the timer is %e sec +/- %e, start time = %e.\n", res, acc, time_seconds(&profStartTime));
    fprintf(profFile, "Name: (group %%) (execution time) (main loop %%)\n");

    profLevel = -1;		// Sets initial level to "main loop".
    profEvent = profEvents;
    profAccumEvent = 0;

    if(atexit(profiler_exit))	// Submits deallocator (to close file anyway).
        error("profiler_init: cannot submit deallocator.");

    memset(profEvents, 0, mc_eventCacheN * sizeof(sample_t));	// Cleans all accumulated values.

    profLongestName = 0;
    for(int bind = 0; bind < mc_prof_N; ++bind)	// Updates precalcs for formatted output.
    {
        profBinds[bind].nameLenght = strlen(profBinds[bind].name);
        profLongestName = (profLongestName < profBinds[bind].nameLenght) ? profBinds[bind].nameLenght : profLongestName;
    }
}
double timer::stop()
{
    return time_seconds(_timer_, time_now());
}
Exemple #3
0
kate_float time_float_seconds(kate_float t)
{
  return time_milliseconds(t)/(kate_float)1000+time_seconds(t);
}
double timer::stop(timer start)
{
    return time_seconds(start, time_now());
}