From af3be5f96463bcba6ddf4cd26e2ead9d925287b1 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 10 Feb 2009 15:57:34 -0400 Subject: Wrote the beginnings of a new "stats" command. --- src/output.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/output.cc') diff --git a/src/output.cc b/src/output.cc index 593ce909..752d6dd2 100644 --- a/src/output.cc +++ b/src/output.cc @@ -84,6 +84,37 @@ void format_xacts::operator()(xact_t& xact) } } +void gather_statistics::flush() +{ + std::ostream& out(report.output_stream); + + out << "Statistics gathered for this report:" << std::endl + << " Total entries: " ; + + out << std::right; + out.width(6); + out << statistics.total_entries << std::endl + << " Total transactions: "; + + out << std::right; + out.width(6); + out << statistics.total_xacts << std::endl; + + out.flush(); +} + +void gather_statistics::operator()(xact_t& xact) +{ + if (last_entry != xact.entry) { + statistics.total_entries++; + last_entry = xact.entry; + } + if (last_xact != &xact) { + statistics.total_xacts++; + last_xact = &xact; + } +} + void format_entries::format_last_entry() { bool first = true; -- cgit v1.2.3