projects
/
mtp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
02b0f31
)
Now measures the elapsed time more precisely with gettimeofday.
author
Francois Fleuret
<francois@fleuret.org>
Wed, 19 Dec 2012 16:21:49 +0000
(17:21 +0100)
committer
Francois Fleuret
<francois@fleuret.org>
Wed, 19 Dec 2012 16:21:49 +0000
(17:21 +0100)
mtp.cc
patch
|
blob
|
history
diff --git
a/mtp.cc
b/mtp.cc
index
36f09f1
..
61dcc21
100644
(file)
--- a/
mtp.cc
+++ b/
mtp.cc
@@
-24,13
+24,20
@@
#include <iostream>
#include <fstream>
#include <iostream>
#include <fstream>
+#include <sys/time.h>
using namespace std;
#include "mtp_tracker.h"
using namespace std;
#include "mtp_tracker.h"
+scalar_t diff_in_second(struct timeval *start, struct timeval *end) {
+ return
+ scalar_t(end->tv_sec - start->tv_sec) +
+ scalar_t(end->tv_usec - start->tv_usec)/1000000;
+}
+
int main(int argc, char **argv) {
int main(int argc, char **argv) {
- time
_t
start_time, end_time;
+ time
val
start_time, end_time;
if(argc < 2) {
cerr << argv[0] << " <tracker file>" << endl;
if(argc < 2) {
cerr << argv[0] << " <tracker file>" << endl;
@@
-47,16
+54,16
@@
int main(int argc, char **argv) {
tracker->read(in_tracker);
cout << "Building the graph ... "; cout.flush();
tracker->read(in_tracker);
cout << "Building the graph ... "; cout.flush();
-
start_time = time(
0);
+
gettimeofday(&start_time,
0);
tracker->build_graph();
tracker->build_graph();
-
end_time = time(
0);
- cout << "done (" <<
end_time - start_time
<< "s)." << endl;
+
gettimeofday(&end_time,
0);
+ cout << "done (" <<
diff_in_second(&start_time, &end_time)
<< "s)." << endl;
cout << "Tracking ... "; cout.flush();
cout << "Tracking ... "; cout.flush();
-
start_time = time(
0);
+
gettimeofday(&start_time,
0);
tracker->track();
tracker->track();
-
end_time = time(
0);
- cout << "done (" <<
end_time - start_time
<< "s)." << endl;
+
gettimeofday(&end_time,
0);
+ cout << "done (" <<
diff_in_second(&start_time, &end_time)
<< "s)." << endl;
ofstream out_traj("result.trj");
tracker->write_trajectories(&out_traj);
ofstream out_traj("result.trj");
tracker->write_trajectories(&out_traj);