From 52680e9bc1eda7474de96ff3ade6518534e639f2 Mon Sep 17 00:00:00 2001
From: "Zooko O'Whielacronx zooko@zooko.com" <zooko@zooko.com>
Date: Wed, 28 Mar 2007 06:12:59 +0530
Subject: [PATCH] add verbosity option to bench

darcs-hash:0f67e7c0336dd9a7d32ead1dfb997529bb41f3e5
---
 pyfec/fec/test/bench_pyfec.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/pyfec/fec/test/bench_pyfec.py b/pyfec/fec/test/bench_pyfec.py
index ddb7e9f..58909c4 100644
--- a/pyfec/fec/test/bench_pyfec.py
+++ b/pyfec/fec/test/bench_pyfec.py
@@ -27,7 +27,7 @@ import fec
 
 import array, random
 
-def bench_encode_to_files_shuffle_decode_from_files():
+def bench_encode_to_files_shuffle_decode_from_files(verbose=False):
     FILESIZE=1000000
     CHUNKSIZE=4096
     PREFIX="testshare"
@@ -47,7 +47,8 @@ def bench_encode_to_files_shuffle_decode_from_files():
         st = time.time()
         fec.filefec.encode_to_files(infile, PREFIX, K, M)
         so = time.time()
-        print "Encoded %s byte file into %d share files in %0.2f seconds, or %0.2f million bytes per second" % (FILESIZE, M, so-st, FILESIZE/((so-st)*1000000),)
+        if verbose:
+            print "Encoded %s byte file into %d share files in %0.2f seconds, or %0.2f million bytes per second" % (FILESIZE, M, so-st, FILESIZE/((so-st)*1000000),)
         enctime = so-st
         # Now delete m-k of the tempfiles at random.
         tempfs = [ f for f in os.listdir(".") if f.startswith(PREFIX) ]
@@ -58,7 +59,8 @@ def bench_encode_to_files_shuffle_decode_from_files():
         st = time.time()
         fec.filefec.decode_from_files(recoveredfile, 1000000, PREFIX, K, M)
         so = time.time()
-        print "Decoded %s byte file from %d share files in %0.2f seconds, or %0.2f million bytes per second" % (FILESIZE, K, so-st, FILESIZE/((so-st)*1000000),)
+        if verbose:
+            print "Decoded %s byte file from %d share files in %0.2f seconds, or %0.2f million bytes per second" % (FILESIZE, K, so-st, FILESIZE/((so-st)*1000000),)
         return enctime + (so-st)
     finally:
         # os.remove("tmpranddata")
-- 
2.45.2