Main.java

49 lines | 1.643 kB Blame History Raw Download
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufrgs.inf.prosoft.approachescomparison.adapter;

import br.ufrgs.inf.prosoft.memoizeit.MemoizeIt;
import br.ufrgs.inf.prosoft.memoizeit.Method;
import br.ufrgs.inf.prosoft.memoizeit.graph.Graph;
import br.ufrgs.inf.prosoft.trace.Trace;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author romulo
 */
public class Main {

    private static final Logger LOGGER = Logger.getLogger(Main.class.getName());

    public static void main(String[] args) {
        System.setProperty("java.util.logging.SimpleFormatter.format", "[%1$tF %1$tT+%1$tL] [%4$-7s] [MemoizeIt] %5$s %n");

        String tracePath = null;
        String callGraphPath = null;
        if (args.length < 2) {
            System.err.println("<TracePath> <CallGraphPath>");
            System.exit(1);
        } else {
            tracePath = args[0];
            callGraphPath = args[1];
        }
        LOGGER.log(Level.INFO, "Reading callgraph");
        Graph<String> graph = CallGraphReader.parseFile(callGraphPath);
        LOGGER.log(Level.INFO, "Reading traces");
        List<Trace> traces = TraceReader.partiallyParseFile(tracePath);
        LOGGER.log(Level.INFO, "Grouping methods");
        List<Method> methods = TraceReader.groupByMethods(traces);
        MemoizeIt memoizeIt = new MemoizeIt();
        memoizeIt.setCallGraph(graph);
        memoizeIt.setMethods(methods);
        memoizeIt.run();
        methods.forEach(System.out::println);
    }
}