30 P_TOTAL, P_INIT, P_CIRCUIT, P_NETWORK, P_BASE_OT, P_SETUP, P_OT_EXT, P_GARBLE, P_ONLINE, P_FIRST = P_TOTAL, P_LAST = P_ONLINE
38 static int m_nTimings = P_LAST - P_FIRST + 1;
43 static double getMillies(timeval timestart, timeval timeend) {
44 long time1 = (timestart.tv_sec * 1000000) + (timestart.tv_usec);
45 long time2 = (timeend.tv_sec * 1000000) + (timeend.tv_usec);
47 return (
double) (time2 - time1) / 1000;
51 static double getMillies(timespec timestart, timespec timeend) {
52 long time1 = (timestart.tv_sec * 1000000) + (timestart.tv_nsec / 1000);
53 long time2 = (timeend.tv_sec * 1000000) + (timeend.tv_nsec / 1000);
55 return (
double) (time2 - time1) / 1000;
58 static void StartWatch(
const string& msg, ABYPHASE phase) {
59 if (phase < P_FIRST && phase > P_LAST) {
60 cerr <<
"Phase not recognized: " << phase << endl;
63 gettimeofday(&(m_tTimes[phase].tbegin), NULL);
69 static void StopWatch(
const string& msg, ABYPHASE phase) {
70 if (phase < P_FIRST && phase > P_LAST) {
71 cerr <<
"Phase not recognized: " << phase << endl;
75 gettimeofday(&(m_tTimes[phase].tend), NULL);
76 m_tTimes[phase].timing = getMillies(m_tTimes[phase].tbegin, m_tTimes[phase].tend);
79 cout << msg << m_tTimes[phase].timing <<
" ms " << endl;
84 static void PrintTimings() {
86 cout <<
"Timings: " << endl;
87 cout <<
"Total =\t\t" << m_tTimes[0].timing << unit << endl;
88 cout <<
"Init =\t\t" << m_tTimes[1].timing << unit << endl;
89 cout <<
"CircuitGen =\t" << m_tTimes[2].timing << unit << endl;
90 cout <<
"Network =\t" << m_tTimes[3].timing << unit << endl;
91 cout <<
"BaseOTs =\t" << m_tTimes[4].timing << unit << endl;
92 cout <<
"Setup =\t\t" << m_tTimes[5].timing << unit << endl;
93 cout <<
"OTExtension =\t" << m_tTimes[6].timing << unit << endl;
94 cout <<
"Garbling =\t" << m_tTimes[7].timing << unit << endl;
95 cout <<
"Online =\t" << m_tTimes[8].timing << unit << endl;
98 static double GetTimeForPhase(ABYPHASE phase) {
99 return m_tTimes[phase].timing;