Path: blob/devel/ElmerGUI/netgen/libsrc/general/profiler.hpp
3206 views
#ifndef FILE_NG_PROFILER1#define FILE_NG_PROFILER23/**************************************************************************/4/* File: profiler.hpp */5/* Author: Joachim Schoeberl */6/* Date: 5. Jan. 2005 */7/**************************************************************************/891011#ifdef VTRACE12#include "vt_user.h"13#else14#define VT_USER_START(n)15#define VT_USER_END(n)16#define VT_TRACER(n)17#endif18192021class NgProfiler22{23enum { SIZE = 1000 };2425static long int tottimes[SIZE];26static long int starttimes[SIZE];27static long int counts[SIZE];28static string names[SIZE];29static int usedcounter[SIZE];3031int total_timer;32public:33NgProfiler();34~NgProfiler();35static int CreateTimer (const string & name);3637static void StartTimer (int nr)38{39starttimes[nr] = clock(); counts[nr]++;40VT_USER_START (const_cast<char*> (names[nr].c_str()));41}42static void StopTimer (int nr)43{44tottimes[nr] += clock()-starttimes[nr];45VT_USER_END (const_cast<char*> (names[nr].c_str()));46}4748//static void Print (ostream & ost);49static void Print (FILE * prof);5051class RegionTimer52{53int nr;54public:55RegionTimer (int anr) : nr(anr)56{ StartTimer (nr); }57~RegionTimer () { StopTimer (nr); }58};59};6061#endif626364