gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] twogtp.py enhancement


From: Arend Bayer
Subject: [gnugo-devel] twogtp.py enhancement
Date: Tue, 13 May 2003 18:38:35 +0200 (CEST)


- add CPU time reporting to final twogtp.py output

Arend

Index: interface/gtp_examples/twogtp.py
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/gtp_examples/twogtp.py,v
retrieving revision 1.5
diff -u -p -r1.5 twogtp.py
--- interface/gtp_examples/twogtp.py    15 Mar 2003 22:01:57 -0000      1.5
+++ interface/gtp_examples/twogtp.py    13 May 2003 16:41:05 -0000
@@ -190,6 +190,12 @@ class GTP_player:
     def score(self):
         return self.final_score(self)

+    def cputime(self):
+       if (self.is_known_command("cputime")):
+           return self.connection.exec_cmd("cputime")
+       else:
+           return "0"
+

 class GTP_game:

@@ -417,6 +423,12 @@ class GTP_game:

     def result(self):
         return (self.resultw, self.resultb)
+
+    def cputime(self):
+       cputime = {}
+       cputime["white"] = self.whiteplayer.cputime()
+       cputime["black"] = self.blackplayer.cputime()
+       return cputime

     def quit(self):
         self.blackplayer.quit()
@@ -534,8 +546,9 @@ class GTP_match:
                 last_color = ""
                 last_streak = 0
            results.append(result)
+       cputime = game.cputime()
         game.quit()
-        return results
+        return results, cputime


 # ================================================================
@@ -664,7 +677,7 @@ if endgame_filelist != []:
          % (len(results), win_black, win_white)

 else:
-    results = match.play(games, sgfbase)
+    results, cputimes = match.play(games, sgfbase)

     i = 0
     for resw, resb in results:
@@ -673,3 +686,7 @@ else:
            print "Game %d: %s" % (i, resw)
        else:
            print "Game %d: %s %s" % (i, resb, resw)
+    if (cputimes["white"] != "0"):
+       print "White: %ss CPU time" % cputimes["white"]
+    if (cputimes["black"] != "0"):
+       print "Black: %ss CPU time" % cputimes["black"]





reply via email to

[Prev in Thread] Current Thread [Next in Thread]