From 851e389dffdd6996ea32d70defb8906de80b9edc Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Mon, 14 Dec 2009 20:35:11 -0500 Subject: few small fixes of alignment tools, add new orthographic similarity feature for word aligner, final naming of directories, libraries in cdec --- decoder/timing_stats.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 decoder/timing_stats.cc (limited to 'decoder/timing_stats.cc') diff --git a/decoder/timing_stats.cc b/decoder/timing_stats.cc new file mode 100644 index 00000000..85b95de5 --- /dev/null +++ b/decoder/timing_stats.cc @@ -0,0 +1,24 @@ +#include "timing_stats.h" + +#include + +using namespace std; + +map Timer::stats; + +Timer::Timer(const string& timername) : start_t(clock()), cur(stats[timername]) {} + +Timer::~Timer() { + ++cur.calls; + const clock_t end_t = clock(); + const double elapsed = (end_t - start_t) / 1000000.0; + cur.total_time += elapsed; +} + +void Timer::Summarize() { + for (map::iterator it = stats.begin(); it != stats.end(); ++it) { + cerr << it->first << ": " << it->second.total_time << " secs (" << it->second.calls << " calls)\n"; + } + stats.clear(); +} + -- cgit v1.2.3