/* vim: set sw=4 sts=4 et foldmethod=syntax : */ import java.util.*; import java.io.*; public class BigTable { public static void main(String[] args) throws IOException { if (args.length < 2) { System.out.println("Usage: java BigTable baselinesDirectory run25Directory run50Directory ..."); System.exit(1); } File baselinesDir = new File(args[0]); List runDirs = new LinkedList(Arrays.asList(args)); /* designed by monkeys */ runDirs.remove(0); Map > runJobTime = new TreeMap >(); Map jobResult = new TreeMap(); Map baselines = new TreeMap(); for (String p : baselinesDir.list()) { if (! p.endsWith(".txt")) continue; String pn = p.substring(0, p.indexOf('.')); Scanner sc = new Scanner(new File(baselinesDir, p)); int size = sc.nextInt(); long nodes = sc.nextLong(); long time = sc.nextLong(); sc.close(); baselines.put(pn, time / 1000); } for (String r : runDirs) { runJobTime.put(r, new TreeMap()); File runDir = new File(r); for (String p : runDir.list()) { File outputDir = new File(new File(new File(r), p), "output"); long startTime = Long.MAX_VALUE, stopTime = -1; int bestClique = 0; for (String f : outputDir.list()) { if (f.endsWith(".start")) { Scanner sc = new Scanner(new File(outputDir, f)); long thisStartTime = sc.nextLong(); startTime = Math.min(startTime, thisStartTime); sc.close(); } else if (f.endsWith(".stop")) { Scanner sc = new Scanner(new File(outputDir, f)); long thisStopTime = sc.nextLong(); stopTime = Math.max(stopTime, thisStopTime); sc.close(); } } File resultsDir = new File(new File(new File(r), p), "results"); for (String f : resultsDir.list()) { if (! f.contains(".job.")) continue; File scf = new File(resultsDir, f); Scanner sc = new Scanner(scf); try { int size = sc.nextInt(); long nodes = sc.nextLong(); long time = sc.nextLong(); bestClique = Math.max(bestClique, size); } catch (Exception e) { } sc.close(); } runJobTime.get(r).put(p, stopTime - startTime); if (null == jobResult.get(p)) jobResult.put(p, bestClique); else if (jobResult.get(p) != bestClique) jobResult.put(p, Math.max(bestClique, jobResult.get(p))); } } System.out.printf("%-12s & %-5s & %-10s", "Problem", "Omega", "Baseline"); for (String r : runDirs) { String rs = (new File(r)).getName(); System.out.printf(" & %-8s & %-8s", rs, "(gain)"); } System.out.printf(" \\\n"); for (String p : jobResult.keySet()) { System.out.printf("%-12s & %-5d ", p, jobResult.get(p)); Long baseline = baselines.get(p); if (null == baseline) System.out.printf("& %-10s", ""); else System.out.printf("& %-10d", baseline); for (String r : runDirs) { String rs = (new File(r)).getName(); if (null == runJobTime.get(r).get(p)) System.out.printf(" & %-8s & %-8s", "", ""); else { if (null == baseline) { System.out.printf(" & %-8d & %-8s", runJobTime.get(r).get(p), ""); } else { double gain = baseline / (0.0 + runJobTime.get(r).get(p)); String gains = String.format("(%.1f)", gain); System.out.printf(" & %-8d & %-8s", runJobTime.get(r).get(p), gains); } } } System.out.printf(" \\\n"); } } }