7514865459fd

Add skeleton of benchmark script
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 24 Aug 2016 13:57:32 +0000
parents f7cc5624141a
children 9da17791e5da
branches/tags (none)
files .hgignore contrib/gdl-benchmark/README.markdown contrib/gdl-benchmark/run-temperance.ros

Changes

--- a/.hgignore	Wed Aug 24 00:12:16 2016 +0000
+++ b/.hgignore	Wed Aug 24 13:57:32 2016 +0000
@@ -5,3 +5,4 @@
 STATUS
 bench-results.txt
 profile.out
+contrib/gdl-benchmark/run-temperance
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/gdl-benchmark/README.markdown	Wed Aug 24 13:57:32 2016 +0000
@@ -0,0 +1,4 @@
+An thin wrapper to plug Temperance into [Stephan and Yngvi's GDL reasoner
+benchmarking library thing][paper].
+
+[paper]: http://cgi.cse.unsw.edu.au/~mit/GGP/GIGA-13-Proceedings.pdf#page=55
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/gdl-benchmark/run-temperance.ros	Wed Aug 24 13:57:32 2016 +0000
@@ -0,0 +1,94 @@
+#!/bin/sh
+#|-*- mode:lisp -*-|#
+#|
+exec ros -Q -- $0 "$@"
+|#
+
+;;;; Dependencies -------------------------------------------------------------
+(ql:quickload 'unix-opts :silent t)
+(ql:quickload 'split-sequence :silent t)
+(ql:quickload 'temperance :silent t)
+
+;;;; Benchmarking -------------------------------------------------------------
+(defun run (modes limit gdl-file trace-file)
+  (print modes)
+  (print limit)
+  (print gdl-file)
+  (print trace-file))
+
+
+;;;; CLI ----------------------------------------------------------------------
+(defun program-name ()
+  ;; dammit roswell
+  (let ((ros-opts (uiop:getenv "ROS_OPTS")))
+    (if ros-opts
+      (read-from-string (second (assoc "script"
+                                       (let ((*read-eval*))
+                                         (read-from-string ros-opts))
+                                       :test 'equal)))
+      (first (opts:argv)))))
+
+
+(opts:define-opts
+  (:name :help
+   :description "print this help text"
+   :short #\h
+   :long "help")
+  (:name :verbose
+   :description "verbose output"
+   :short #\v
+   :long "verbose"))
+
+
+(defparameter *required-options*
+  (format nil "Required parameters:
+
+  SEARCH-MODES   A space-separated list of one or more of {dfs, fdfs, mc}.
+
+  LIMIT          A positive integer denoting the playclock limit (for dfs/mc)
+                 or depth limit (for fdfs).
+
+  GDL-FILE       Path to the GDL file to run.  Does NOT need the version with the
+                 extra base propositions.
+
+  TRACE-FILE     Path to the corresponding trace file."))
+
+(defparameter *verbose* nil)
+
+
+(defun usage ()
+  (let ((prog (program-name)))
+    (opts:describe
+      :prefix (format nil "~A - benchmark Temperance for GDL reasoning" prog)
+      :suffix *required-options*
+      :usage-of prog
+      :args "SEARCH-MODES LIMIT GDL-FILE TRACE-FILE")))
+
+(defun die (message &rest args)
+  (apply #'format *error-output* message args)
+  #+sbcl (sb-ext:exit :code 1)
+  #-sbcl (quit))
+
+
+(defun main (&rest argv)
+  (block nil
+    (multiple-value-bind (options arguments)
+        (opts:get-opts argv)
+
+      (setf *verbose* (getf options :verbose))
+      (when (or (getf options :help)
+                (not (= 4 (length arguments))))
+        (usage)
+        (return))
+
+      (destructuring-bind (modes limit gdl-file trace-file) arguments
+        (run (split-sequence:split-sequence #\space modes
+                                            :remove-empty-subseqs t)
+             (handler-case
+                 (parse-integer limit)
+               (parse-error (e)
+                 (declare (ignore e))
+                 (die "ERROR: limit '~A' is not an integer~%" limit)))
+             gdl-file
+             trace-file)))))
+