/* vim: set sw=4 sts=4 et foldmethod=syntax : */ import java.util.*; import java.io.*; public class MachineInfo { public static void main(String[] args) throws IOException { if (1 != args.length) { System.out.println("Usage: java MachineInfo problemDirectory"); System.exit(1); } File resultsDir = new File(new File(args[0]), "results"); final Map > jobSizesByMachine = new TreeMap >(); for (String f : resultsDir.list()) { if (! f.contains(".job.")) continue; File r = new File(resultsDir, f); Scanner sc = new Scanner(r); try { int size = sc.nextInt(); long nodes = sc.nextLong(); long time = sc.nextLong(); String host = f.substring(1 + f.indexOf('.', f.indexOf('.') + 1)); if (host.indexOf('.') != -1) host = host.substring(0, host.indexOf('.')); if (null == jobSizesByMachine.get(host)) jobSizesByMachine.put(host, new ArrayList()); jobSizesByMachine.get(host).add(nodes); } catch (Exception e) { } sc.close(); } ArrayList machinesBySize = new ArrayList(jobSizesByMachine.keySet()); Collections.sort(machinesBySize, new Comparator() { @Override public int compare(String l, String r) { long lv = 0, rv = 0; /* don't admit to this in public */ for (long v : jobSizesByMachine.get(l)) lv += v; for (long v : jobSizesByMachine.get(r)) rv += v; return lv < rv ? -1 : lv == rv ? 0 : 1; } }); for (String h : machinesBySize) { long total = 0, largest = 0; for (long v : jobSizesByMachine.get(h)) { total += v; largest = Math.max(largest, v); } System.out.printf("%s %d %d\n", h, total, largest); } } }