#!/usr/bin/env python

import os, re, sys

# Parse output from ant benchmarkcluster and output a java properties file.

bestsingle = 0.0
bestdouble = 0.0
bestcluster = 0.0
clustersize = 0

logstring = "\d+ \[main\] INFO COMPILER - "
hostinfopattern = re.compile(logstring +
    "Catalog leader: volt.. hosts, sites (\d+), (\d+)")
benchmarkpattern = re.compile(logstring +
    "Path to catalog file:.*/([^/]+)\-ddl\.sql")
resultpattern = re.compile("Transactions per second: (\d+\.\d*)")
clientpattern = re.compile("               volt(.*):(.*):")

print "# benchmarkcluster results"
print "# benchmark-hosts-sites-clients-processes = transactions per second"

while True:
    line = sys.stdin.readline()
    if line == '':
        if bestsingle != 0.0:
            fd = os.open("bestsingle.properties", os.O_CREAT | os.O_WRONLY)
            os.write(fd, "YVALUE = " + str(bestsingle) + "\n")
            os.close(fd)
        if bestdouble != 0.0:
            fd = os.open("bestdouble.properties", os.O_CREAT | os.O_WRONLY)
            os.write(fd, "YVALUE = " + str(bestdouble) + "\n")
            os.close(fd)
        if bestcluster != 0.0:
            fd = os.open("bestcluster.properties", os.O_CREAT | os.O_WRONLY)
            os.write(fd, "YVALUE = " + str(bestcluster) + "\n")
            os.close(fd)
        if bestcluster != 0.0:
            fd = os.open("clustersize.properties", os.O_CREAT | os.O_WRONLY)
            os.write(fd, "YVALUE = " + str(clustersize) + "\n")
            os.close(fd)
        exit(0)

    match = hostinfopattern.match(line)
    if match:
        hosts = int(match.group(1))
        sites = int(match.group(2))

    match = benchmarkpattern.match(line)
    if match:
        benchmark = match.group(1)

    match = resultpattern.match(line)
    if match:
        result = float(match.group(1))

    match = clientpattern.match(line)
    if match:
        clients = set()
        processes = set()
        # read the rest of the contiguous clients
        while match:
            clients.add(match.group(1))
            processes.add(match.group(2))
            line = sys.stdin.readline()
            if line == '': break # whoops, truncated file!  try to recover
            match = clientpattern.match(line)
        if (benchmark == "tpcc") and (hosts == 1) and (result > bestsingle):
            bestsingle = result
        if (benchmark == "tpcc") and (hosts == 2) and (result > bestdouble):
            bestdouble = result
        if (benchmark == "tpcc") and (hosts >= 5) and (result > bestcluster):
            clustersize = hosts
            bestcluster = result
        # output properties
        print benchmark + "-" + str(hosts) + "h-" + str(sites) + "s-" + \
            str(len(clients)) + "c-" + str(len(processes)) + "p = " + \
            str(result)
        # prepare to parse next test run
        hosts = ""
        sites = ""
        benchmark = ""
        result = ""

@@ -165,16 +165,32 @@
 r = 0.0%0A
+bestdozen = 0.0%0A
 clusters
@@ -1506,32 +1506,223 @@
    os.close(fd)%0A
+        if bestdozen != 0.0:%0A            fd = os.open(%22bestdozen.properties%22, os.O_CREAT %7C os.O_WRONLY)%0A            os.write(fd, %22YVALUE = %22 + str(bestdozen) + %22%5Cn%22)%0A            os.close(fd)%0A
         exit(0)%0A
@@ -2472,36 +2472,48 @@
 hmark == %22tpcc%22)
- and
+:%0A            if
  (hosts == 1) an
@@ -2545,24 +2545,28 @@
             
+    
 bestsingle =
@@ -2585,36 +2585,14 @@
     
-if (benchmark == %22tpcc%22) and
+    if
  (ho
@@ -2636,24 +2636,28 @@
             
+    
 bestdouble =
@@ -2672,39 +2672,34 @@
         
-if (benchmark == %22tpcc%22
+    if (hosts %3E= 5
 ) and (h
@@ -2699,28 +2699,28 @@
  and (hosts 
-%3E= 5
+%3C= 6
 ) and (resul
@@ -2737,16 +2737,20 @@
 uster):%0A
+    
         
@@ -2781,24 +2781,28 @@
             
+    
 bestcluster 
@@ -2802,32 +2802,122 @@
 luster = result%0A
+            if (hosts == 12) and (result %3E bestdozen):%0A                bestdozen = result%0A
         # output

Add a 12-node cluster series.