HElib  1.0
Implementing Homomorphic Encryption
 All Classes Files Functions Variables Friends Pages
timing.h
Go to the documentation of this file.
1 /* Copyright (C) 2012,2013 IBM Corp.
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License along
13  * with this program; if not, write to the Free Software Foundation, Inc.,
14  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  */
35 #ifndef _TIMING_H_
36 #define _TIMING_H_
37 #include <iostream>
38 
39 // Activate/deactivate/check-status of timing
40 extern bool FHEtimersOn;
41 inline void setTimersOn() { FHEtimersOn=true; }
42 inline void setTimersOff() { FHEtimersOn=false; }
43 inline bool areTimersOn() { return FHEtimersOn; }
44 
46 void startFHEtimer(const char *fncName); // start counting
48 void stopFHEtimer(const char *fncName); // pause counting
50 void resetFHEtimer(const char *fncName); // reset value to zero
52 double getTime4func(const char *fncName); // returns time in seconds
54 long getNumCalls4func(const char *fncName); // returns # of calls
55 
56 void resetAllTimers();
58 void printAllTimers(std::ostream& str=std::cerr);
59 
60 #define FHE_TIMER_START {if (areTimersOn()) startFHEtimer(__func__);}
61 #define FHE_TIMER_STOP {if (areTimersOn()) stopFHEtimer(__func__);}
62 
63 #define FHE_NTIMER_START(n) {if (areTimersOn()) startFHEtimer(n);}
64 #define FHE_NTIMER_STOP(n) {if (areTimersOn()) stopFHEtimer(n);}
65 
66 #endif // _TIMING_H_