From 5e3c920e1628519001210a54ba62bad81103551c Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Wed, 2 Dec 2009 15:17:31 +0000 Subject: [PATCH 1/3] add timing info to log --- pyfpdb/HUD_main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index dfe1c5fa..2bb3a995 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -63,6 +63,9 @@ elif os.name == 'nt': import Hud +log = Configuration.get_logger("logging.conf") + + class HUD_main(object): """A main() object to own both the read_stdin thread and the gui.""" # This class mainly provides state for controlling the multiple HUDs. @@ -192,6 +195,7 @@ class HUD_main(object): while 1: # wait for a new hand number on stdin new_hand_id = sys.stdin.readline() + t0 = time() new_hand_id = string.rstrip(new_hand_id) if new_hand_id == "": # blank line means quit self.destroy() @@ -206,6 +210,7 @@ class HUD_main(object): print "db error: skipping %s" % new_hand_id sys.stderr.write("Database error: could not find hand %s.\n" % new_hand_id) continue + t1 = time() if type == "tour": # hand is from a tournament temp_key = tour_number @@ -217,8 +222,10 @@ class HUD_main(object): # get stats using hud's specific params and get cards self.db_connection.init_hud_stat_vars( self.hud_dict[temp_key].hud_params['hud_days'] , self.hud_dict[temp_key].hud_params['h_hud_days']) + t2 = time() stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_dict[temp_key].hud_params ,self.hero_ids[site_id], num_seats) + t3 = time() try: self.hud_dict[temp_key].stat_dict = stat_dict except KeyError: # HUD instance has been killed off, key is stale @@ -239,8 +246,10 @@ class HUD_main(object): else: # get stats using default params--also get cards self.db_connection.init_hud_stat_vars( self.hud_params['hud_days'], self.hud_params['h_hud_days'] ) + t4 = time() stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_params ,self.hero_ids[site_id], num_seats) + t5 = time() cards = self.db_connection.get_cards(new_hand_id) comm_cards = self.db_connection.get_common_cards(new_hand_id) if comm_cards != {}: # stud! @@ -264,6 +273,9 @@ class HUD_main(object): else: sys.stderr.write('Table "%s" no longer exists\n', table_name) + t6 = time() + log.info("HUD_main.read_stdin: hand read in %4.3f seconds (%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f)" + % (t6-t0,t1-t0,t2-t0,t3-t0,t4-t0,t5-t0,t6-t0)) self.db_connection.connection.rollback() if __name__== "__main__": From cd65aae3743ec91f2e67818364cb8db879deff74 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Thu, 3 Dec 2009 20:20:42 +0000 Subject: [PATCH 2/3] allow legend box to work in python 2.5 --- pyfpdb/GuiGraphViewer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index 76c80f2e..9daa940f 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -196,7 +196,10 @@ class GuiGraphViewer (threading.Thread): self.ax.plot(green, color='green', label='Hands: %d\nProfit: $%.2f' %(len(green), green[-1])) self.ax.plot(blue, color='blue', label='Showdown: $%.2f' %(blue[-1])) self.ax.plot(red, color='red', label='Non-showdown: $%.2f' %(red[-1])) - self.ax.legend(loc='best', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) + if sys.version[0:3] == '2.5': + self.ax.legend(loc='best', shadow=True, prop=FontProperties(size='smaller')) + else: + self.ax.legend(loc='best', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) self.graphBox.add(self.canvas) From c9b99273156346a72901448c47582c72bdd47600 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Thu, 3 Dec 2009 21:02:05 +0000 Subject: [PATCH 3/3] fix new timing code so it actually works\! --- pyfpdb/HUD_main.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index c3c66d70..c3599a3b 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -195,7 +195,8 @@ class HUD_main(object): while 1: # wait for a new hand number on stdin new_hand_id = sys.stdin.readline() - t0 = time() + t0 = time.time() + t1 = t2 = t3 = t4 = t5 = t6 = t0 new_hand_id = string.rstrip(new_hand_id) if new_hand_id == "": # blank line means quit self.destroy() @@ -210,7 +211,7 @@ class HUD_main(object): print "db error: skipping %s" % new_hand_id sys.stderr.write("Database error: could not find hand %s.\n" % new_hand_id) continue - t1 = time() + t1 = time.time() if type == "tour": # hand is from a tournament temp_key = tour_number @@ -222,10 +223,10 @@ class HUD_main(object): # get stats using hud's specific params and get cards self.db_connection.init_hud_stat_vars( self.hud_dict[temp_key].hud_params['hud_days'] , self.hud_dict[temp_key].hud_params['h_hud_days']) - t2 = time() + t2 = time.time() stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_dict[temp_key].hud_params ,self.hero_ids[site_id], num_seats) - t3 = time() + t3 = time.time() try: self.db_connection.init_hud_stat_vars( self.hud_dict[temp_key].hud_params['hud_days'] , self.hud_dict[temp_key].hud_params['h_hud_days']) @@ -249,10 +250,10 @@ class HUD_main(object): else: # get stats using default params--also get cards self.db_connection.init_hud_stat_vars( self.hud_params['hud_days'], self.hud_params['h_hud_days'] ) - t4 = time() + t4 = time.time() stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_params ,self.hero_ids[site_id], num_seats) - t5 = time() + t5 = time.time() cards = self.db_connection.get_cards(new_hand_id) comm_cards = self.db_connection.get_common_cards(new_hand_id) if comm_cards != {}: # stud! @@ -276,8 +277,8 @@ class HUD_main(object): else: sys.stderr.write('Table "%s" no longer exists\n' % table_name) - t6 = time() - log.info("HUD_main.read_stdin: hand read in %4.3f seconds (%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f)" + t6 = time.time() + log.info("HUD_main.read_stdin: hand read in %4.3f seconds (%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f)" % (t6-t0,t1-t0,t2-t0,t3-t0,t4-t0,t5-t0,t6-t0)) self.db_connection.connection.rollback()