changeset 1429:b2b8e4a74cd6

runtime: print statistics with --statistics option.
author Martin Geisler <mg@cs.au.dk>
date Sun, 24 Jan 2010 17:29:26 +0100
parents e120e8967257
children 4efa3caf521e
files viff/runtime.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/viff/runtime.py	Thu Jan 21 11:31:36 2010 +0100
+++ b/viff/runtime.py	Sun Jan 24 17:29:26 2010 +0100
@@ -525,6 +525,8 @@
                          help="Collect and print profiling information.")
         group.add_option("--track-memory", action="store_true",
                          help="Track memory usage over time.")
+        group.add_option("--statistics", action="store_true",
+                         help="Print statistics on shutdown.")
         group.add_option("--no-socket-retry", action="store_true",
                          default=False, help="Fail rather than keep retrying "
                          "to connect if port is already in use.")
@@ -542,7 +544,8 @@
                             ssl=have_openssl,
                             deferred_debug=False,
                             profile=False,
-                            track_memory=False)
+                            track_memory=False,
+                            statistics=False)
 
     def __init__(self, player, threshold, options=None):
         """Initialize runtime.
@@ -1026,6 +1029,10 @@
     runtime = runtime_class(players[id], threshold, options)
     factory = ShareExchangerFactory(runtime, players, result)
 
+    if options and options.statistics:
+        reactor.addSystemEventTrigger("after", "shutdown",
+                                      runtime.print_transferred_data)
+
     if options and options.ssl:
         print "Using SSL"
         from twisted.internet.ssl import ContextFactory