guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, string_abstraction2, updated. release_


From: Michael Gran
Subject: [Guile-commits] GNU Guile branch, string_abstraction2, updated. release_1-9-1-151-g580eca3
Date: Sun, 16 Aug 2009 13:59:08 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=580eca3fbc5021de21274798f0dfd37bafb5c265

The branch, string_abstraction2 has been updated
       via  580eca3fbc5021de21274798f0dfd37bafb5c265 (commit)
       via  05263b88a7c174084f8245e05ce042d7d5d3e8c6 (commit)
      from  830e63fab1e54d94d5d5a5a4a1c7babe0a2530b9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 580eca3fbc5021de21274798f0dfd37bafb5c265
Author: Michael Gran <address@hidden>
Date:   Sun Aug 16 06:56:25 2009 -0700

    Char and string benchmarks
    
    * benchmark-suite/benchmarks/chars.bm: new file
    
    * benchmark-suite/benchmarks/strings.bm: new file

commit 05263b88a7c174084f8245e05ce042d7d5d3e8c6
Author: Michael Gran <address@hidden>
Date:   Sun Aug 16 06:54:31 2009 -0700

    Script to prep benchmark logs for gnuplot
    
    * benchmark-suite/benchplot: a benchmark log to gnuplot load file
      conversion script

-----------------------------------------------------------------------

Summary of changes:
 benchmark-suite/benchmarks/chars.bm   |   57 ++++++++
 benchmark-suite/benchmarks/strings.bm |   67 +++++++++
 benchmark-suite/benchplot             |  240 +++++++++++++++++++++++++++++++++
 3 files changed, 364 insertions(+), 0 deletions(-)
 create mode 100644 benchmark-suite/benchmarks/chars.bm
 create mode 100644 benchmark-suite/benchmarks/strings.bm
 create mode 100755 benchmark-suite/benchplot

diff --git a/benchmark-suite/benchmarks/chars.bm 
b/benchmark-suite/benchmarks/chars.bm
new file mode 100644
index 0000000..dc6ad94
--- /dev/null
+++ b/benchmark-suite/benchmarks/chars.bm
@@ -0,0 +1,57 @@
+;;; -*- mode: scheme; coding: latin-1; -*-
+;;; chars.bm
+;;;
+;;; Copyright (C) 2009  Free Software Foundation, Inc.
+;;;
+;;;
+;;; This program is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU Lesser General Public License
+;;; as published by the Free Software Foundation; either version 3, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU Lesser General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with this software; see the file COPYING.LESSER.  If
+;;; not, write to the Free Software Foundation, Inc., 51 Franklin
+;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+(define-module (benchmarks chars)
+  :use-module (benchmark-suite lib))
+
+
+(with-benchmark-prefix "chars"
+                       
+  (benchmark "char" 1000000
+     #\a)
+
+  (benchmark "octal" 1000000
+     #\123)
+
+  (benchmark "char? eq" 1000000
+    (char? #\a))
+
+  (benchmark "char=?" 1000000
+    (char=? #\a #\a))
+
+  (benchmark "char<?" 1000000
+    (char=? #\a #\a))
+
+  (benchmark "char-ci=?" 1000000
+    (char=? #\a #\a))
+
+  (benchmark "char-ci<? " 1000000
+    (char=? #\a #\a))
+
+  (benchmark "char->integer" 1000000
+    (char->integer #\a))
+
+  (benchmark "char-alphabetic?" 1000000
+    (char-upcase #\a))
+
+  (benchmark "char-numeric?" 1000000
+    (char-upcase #\a)))
+
diff --git a/benchmark-suite/benchmarks/strings.bm 
b/benchmark-suite/benchmarks/strings.bm
new file mode 100644
index 0000000..9e44dac
--- /dev/null
+++ b/benchmark-suite/benchmarks/strings.bm
@@ -0,0 +1,67 @@
+;;; -*- mode: scheme; coding: latin-1; -*-
+;;; string.bm
+;;;
+;;; Copyright (C) 2009  Free Software Foundation, Inc.
+;;;
+;;;
+;;; This program is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU Lesser General Public License
+;;; as published by the Free Software Foundation; either version 3, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU Lesser General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with this software; see the file COPYING.LESSER.  If
+;;; not, write to the Free Software Foundation, Inc., 51 Franklin
+;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+(define-module (benchmarks strings)
+  :use-module (benchmark-suite lib))
+
+(define short-string "Hi")
+(define medium-string 
+  "LO, praise of the prowess of people-kings
+of spear-armed Danes, in days long sped,
+we have heard, and what honor the athelings won!
+Oft Scyld the Scefing from squadroned foes,
+from many a tribe, the mead-bench tore,
+awing the earls.")
+(define long-string
+  (string-tabulate 
+   (lambda (n) (integer->char (+ 32 (random 90)))) 
+   1000))
+
+(define short-chlist (string->list short-string))
+(define medium-chlist (string->list medium-string))
+(define long-chlist (string->list long-string))
+
+
+
+(with-benchmark-prefix "strings"
+                       
+  (benchmark "string" 20000
+    (apply string medium-chlist))             
+
+  (benchmark "list->string" 40000
+    (list->string medium-chlist))             
+
+  (benchmark "reverse-list->string" 40000
+    (list->string medium-chlist))             
+
+  (benchmark "make-string" 40000
+    (make-string 250 #\x))
+
+  (benchmark "string-tabulate" 40000
+    (string-tabulate integer->char 250))
+
+  (benchmark "string-join" 20000
+    (string-join (list short-string medium-string long-string) "|" 'suffix))
+
+  (benchmark "string->list" 20000
+    (string->list medium-string))             
+
+  )
\ No newline at end of file
diff --git a/benchmark-suite/benchplot b/benchmark-suite/benchplot
new file mode 100755
index 0000000..bdd00de
--- /dev/null
+++ b/benchmark-suite/benchplot
@@ -0,0 +1,240 @@
+#!/usr/bin/guile 
+!#
+;;;; benchplot --- convertion benchmarks log files into gnuplot files
+;;;; Copyright (C) 2009   Free Software Foundation, Inc.
+;;;;
+;;;; This program is free software; you can redistribute it and/or
+;;;; modify it under the terms of the GNU Lesser General Public
+;;;; License as published by the Free Software Foundation; either
+;;;; version 3, or (at your option) any later version.
+;;;;
+;;;; This program is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;; GNU Lesser General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU Lesser General Public
+;;;; License along with this software; see the file COPYING.LESSER.
+;;;; If not, write to the Free Software Foundation, Inc., 51 Franklin
+;;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+(use-modules (ice-9 getopt-long)
+             (srfi srfi-1)
+             (ice-9 format))
+
+(define VERSIONSTRING "benchplot version 0.0\n")
+(define HELPSTRING "\
+Usage: benchplot [options]
+Convert the output of guile-benchmark to a Gnuplot file. 
+
+
+     -v, --version           Display version
+     -h, --help              Display this help
+     -i, --input=FILENAME    Use FILENAME as the logfile.
+                             Default is 'benchmarks.log'
+     -o, --output=FILENAME   Output gnuplot commands to FILENAME
+                             Default is 'bench.gnup'
+     -d, --datafile=FILENAME Output gnuplot data file to FILENAME
+                             Default is 'bench.dat'
+     -p, --png               Command file will make a PNG
+     -t, --title             Title to appear on plot.
+                             Default is 'Guile Benchmarks'
+")
+(define LABELS-TO-PLOT '(benchmark user/interp bench/interp gc))
+
+;; Parse a row from a configuration log to extract the labels for each
+;; column.
+(define (parse-labels x)
+  ;; all symbols are labels 
+  (filter symbol? x))
+
+;; Parse the whole data set, extracting the numeric timing data
+(define (parse-times data)
+  ;; all numeric columns but the first one is timing data
+  (let ((numeric-data (map 
+                       (lambda (x)
+                         (filter number? x))
+                       data)))
+    (map cdr numeric-data)))
+
+;; Extract those labels for which the mask is true 
+(define (mask-labels mask labels)
+  (filter-map
+   (lambda (msk lbl)
+     (if msk lbl #f))
+   mask
+   labels))
+
+;; Extract the columns for which the mask is true
+(define (mask-times mask times)
+  (map 
+   (lambda (row-of-times)
+     (filter-map
+      (lambda (msk t)
+        (if msk t #f))
+      mask
+      row-of-times))
+   times))
+         
+
+
+
+(define (read-file inport)
+  (let loop ((data '())
+             (current-line (read inport)))
+    (if (eof-object? current-line)
+        data
+        (loop (append data (list current-line))
+              (read inport)))))
+
+;; write the list of lists as a data file
+(define (make-data-file fname list-of-lists)
+  (let ((outport (open-output-file fname)))
+    (map
+     (lambda (lst)
+       (format outport "~{ ~6,5f ~}~%" lst))
+     list-of-lists)
+    fname))
+
+(define (trunc word)
+  (if (< (string-length word) 12)
+      word
+      (substring word 0 11)))
+
+(define (make-command-file fname names labels data-filename png title)
+  (let ((outport (open-output-file fname)))
+
+    (if title
+        (format outport "set title '~a'~%" title))
+
+    (format outport "set ylabel 'Seconds'~%")
+    
+    (if png
+        (begin
+          (format outport "set terminal png~%")
+          (format outport "set output 'tmp.png'~%")))
+
+    ;; Constuct named xtics
+    (format outport "set xtics rotate~%")
+    (format outport "set xtics (")
+    (let loop ((n 0)
+               (name-cur (car names))
+               (rest (cdr names)))
+
+      (if (not (null? rest))
+          (begin
+            (format outport "\"~a\" ~d," (trunc name-cur) n)
+            (loop (+ n 1) (car rest) (cdr rest)))
+          (format outport "\"~a\" ~d)~%" (trunc name-cur) n)))
+
+    ;; Loop over the rows in the data
+    (let loop ((n 1)
+               (label-cur (car labels))
+               (rest (cdr labels)))
+
+      (if (not (null? rest))
+          (begin
+            (if (= n 1)
+                ;; first line
+                (format outport 
+                        "plot '~a' using ~d with linesp title '~a',\\~%"
+                        data-filename n label-cur)
+                ;; middle line
+                (format outport 
+                        "     '~a' using ~d with linesp title '~a',\\~%"
+                        data-filename n label-cur))
+            (loop (+ n 1) (car rest) (cdr rest)))
+          ;; last-line
+          (format outport 
+                  "     '~a' using ~d with linesp title '~a'~%"
+                  data-filename
+                  n
+                  label-cur)))
+
+    (if png
+        (format outport "set output~%")
+        (format outport "pause -1 \"Hit return to continue\"~%"))))
+
+(define (make-plot png title logfile cmdfile datafile)
+  (format #t "Reading the logfile ~S~%" logfile)
+
+  (let* ((inport (open-input-file logfile))
+
+         ;; read in the file
+         (data (read-file inport))
+
+         ;; Take labels for each column of data from the 1st line of
+         ;; the data
+         (labels (parse-labels (car data)))
+         
+         ;; the timing data, a list of lists
+         (times (parse-times data))
+
+         ;; compare the labels with the list of tests to be plotted,
+         ;; and create a mask
+         (mask (map 
+                (lambda (c) (member c LABELS-TO-PLOT)) 
+                labels))
+
+         ;; use the mask to trim down the labels and times
+         (labels-to-plot (mask-labels mask labels))
+         (times-to-plot (mask-times mask times))
+         
+         ;; get the test names
+         ;; The names themselves have the for "CATEGORY: TEST"
+         ;; We'll just use the TEST part, to keep the names shorter.
+         (names (map (lambda (row)
+                       (string-trim-both
+                        (last 
+                         (string-split (first row) #\:))))
+                     data)))
+
+    ;; Create the data file 
+    (format #t "Saving data file as ~S~%" datafile)
+    (make-data-file datafile times-to-plot)
+
+    ;; Create the gnuplot command file
+    (format #t "Saving gnuplot command file as ~S~%" cmdfile)
+    (make-command-file cmdfile names labels-to-plot datafile png title)
+    
+    (format #t "~%Now run 'gnuplot ~a'~%" cmdfile)
+    (if png
+        (format #t "That will generate 'tmp.png'~%"))))
+        
+
+
+(define (main args)
+  (let* ((option-spec '((input (single-char #\i) (value #t))
+                        (output (single-char #\o) (value #t))
+                        (datafile (single-char #\d) (value #t))
+                        (png (single-char #\p) (value #f))
+                        (title (single-char #\t) (value #t))
+                        (version (single-char #\v) (value #f))
+                        (help    (single-char #\h) (value #f))))
+         (options (getopt-long args option-spec))
+         (infile (option-ref options 'input "benchmarks.log"))
+         (outfile (option-ref options 'output "bench.gnup"))
+         (datafile (option-ref options 'datafile "bench.dat"))
+         (png (option-ref options 'png #f))
+         (title (option-ref options 'title "Guile Benchmarks"))
+         (help-wanted (option-ref options 'help #f))
+         (version-wanted (option-ref options 'version #f))
+         (logfile #f))
+    (cond 
+     ((or version-wanted help-wanted)
+      (begin
+        (if version-wanted
+            (display VERSIONSTRING))
+        (if help-wanted
+            (display HELPSTRING))))
+     ((not (file-exists? infile))
+      (error "file not found: ~s" infile))
+     (else
+      (make-plot png title infile outfile datafile)))))
+
+(main (command-line))
+
+
+;;; Local Variables:
+;;; mode: scheme
+;;; End:


hooks/post-receive
-- 
GNU Guile




reply via email to

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