package s3.services.simplejit.optimization;

import java.io.*;

public class SimpleJITCodeSizeResultParser {

    public static void main(String[] args) {
	ResultParser.main(args);
    }

    public static class ResultParser {
	public static void main(String[] args) {
	    if (args.length != 1) {
		System.err.println
		    ("Usage : java ResultParser file");
		System.exit(1);
	    }
	    BufferedReader result_stream = null;
	    try {
		result_stream =
		    new BufferedReader
		    (new FileReader(args[0]));
	    } catch (IOException e) {
		e.printStackTrace();
		System.exit(1);
	    }
	    int bcsize = 0;
	    int irsize = 0;
	    while (true) {
		try {
		    String line = result_stream.readLine();
		    if (line == null)
			break;
		    int idx = line.indexOf(" ");
		    String bc_str = line.substring(0, idx).trim();
		    String ir_str = line.substring(idx, line.length()).trim();
		    bcsize += Integer.parseInt(bc_str);
		    irsize += Integer.parseInt(ir_str);
		} catch (Throwable t) {
		    t.printStackTrace();
		    System.exit(1);
		}
	    }
	    System.out.println("BC size = " + bcsize);
	    System.out.println("IR size = " + irsize);
	}
    }
}
