Skip to content

Commit

Permalink
Fixing how time is measured
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Dec 9, 2013
1 parent 0963a32 commit 44509bf
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class ZTimer
public:
ZTimer() { gettimeofday(&t1,0); t2 = t1; }
void reset() {gettimeofday(&t1,0); t2 = t1;}
int elapsed() { return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1.
tv_usec) / 1000); }
int elapsed() { return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000); }
int split() { gettimeofday(&t2,0); return elapsed(); }
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class ZTimer
public:
ZTimer() : t1(), t2() { gettimeofday(&t1,0); t2 = t1; }
void reset() {gettimeofday(&t1,0); t2 = t1;}
int elapsed() { return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1.
tv_usec) / 1000); }
int elapsed() { return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000); }
int split() { gettimeofday(&t2,0); return elapsed(); }
};
using namespace std;
Expand Down
3 changes: 1 addition & 2 deletions 2012/02/17/bitmaps-are-surprisingly-efficient/bitmapslow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class ZTimer
public:
ZTimer() : t1(), t2() { gettimeofday(&t1,0); t2 = t1; }
void reset() {gettimeofday(&t1,0); t2 = t1;}
int elapsed() { return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1.
tv_usec) / 1000); }
int elapsed() { return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000); }
int split() { gettimeofday(&t2,0); return elapsed(); }
};

Expand Down
3 changes: 1 addition & 2 deletions 2012/03/06/how-fast-is-bit-packing/bitpacking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class ZTimer
public:
ZTimer() : t1(), t2() { gettimeofday(&t1,0); t2 = t1; }
void reset() {gettimeofday(&t1,0); t2 = t1;}
int elapsed() { return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1.
tv_usec) / 1000); }
int elapsed() { return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000); }
int split() { gettimeofday(&t2,0); return elapsed(); }
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ class ZTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
3 changes: 1 addition & 2 deletions 2012/05/31/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
3 changes: 1 addition & 2 deletions 2012/07/23/cumulsum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
3 changes: 1 addition & 2 deletions 2012/07/23/cumulsums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
3 changes: 1 addition & 2 deletions 2012/10/29/benchmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
3 changes: 1 addition & 2 deletions 2012/10/29/storeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
3 changes: 1 addition & 2 deletions 2013/01/31/dynarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
3 changes: 1 addition & 2 deletions extra/benchmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
2 changes: 1 addition & 1 deletion extra/costmod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace std;
public:
WallClockTimer() : t1(), t2(){ gettimeofday(&t1,0); t2 = t1; }
void reset() {gettimeofday(&t1,0); t2 = t1;}
int elapsed() { return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1.tv_usec) / 1000); }
int elapsed() { return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000); }
int split() { gettimeofday(&t2,0); return elapsed(); }
};

Expand Down
3 changes: 1 addition & 2 deletions extra/fastsum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
3 changes: 1 addition & 2 deletions extra/floatvsint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
3 changes: 1 addition & 2 deletions extra/integerlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
2 changes: 1 addition & 1 deletion extra/simdspeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using namespace std;
struct timeval t1, t2;
WallClockTimer() : t1(), t2(){ gettimeofday(&t1,0); t2 = t1; }
void reset() {gettimeofday(&t1,0); t2 = t1;}
int elapsed() { return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1.tv_usec) / 1000); }
int elapsed() { return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000); }
int split() { gettimeofday(&t2,0); return elapsed(); }
};

Expand Down
3 changes: 1 addition & 2 deletions extra/unrolldeltas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down
3 changes: 1 addition & 2 deletions extra/unrolldeltasSIMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class WallClockTimer {
t2 = t1;
}
int elapsed() {
return ((t2.tv_sec - t1.tv_sec) * 1000) + ((t2.tv_usec - t1. tv_usec)
/ 1000);
return (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (t1.tv_sec * 1000 + t1.tv_usec / 1000);
}
int split() {
gettimeofday(&t2, 0);
Expand Down

0 comments on commit 44509bf

Please sign in to comment.