X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fhelper%2Fprofiler%2FVSPLogFileProfiler.java;fp=dol%2Fsrc%2Fdol%2Fhelper%2Fprofiler%2FVSPLogFileProfiler.java;h=dc3b82786edd3bbdef35290c1c6b86c62e43ba6e;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/helper/profiler/VSPLogFileProfiler.java b/dol/src/dol/helper/profiler/VSPLogFileProfiler.java new file mode 100644 index 0000000..dc3b827 --- /dev/null +++ b/dol/src/dol/helper/profiler/VSPLogFileProfiler.java @@ -0,0 +1,73 @@ +/* $Id: VSPLogFileProfiler.java 1 2010-02-24 13:03:05Z haidw $ */ +package dol.helper.profiler; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.StringTokenizer; + +import dol.datamodel.pn.Process; +import dol.datamodel.pn.ProcessNetwork; +import dol.datamodel.pn.ProfilingConfiguration; + +/** + * Class for parsing a file with profiling info and annotate it to a + * process network. + */ +public class VSPLogFileProfiler { + + /** + * Parse the given file and annotate the data to the given process + * network. + * + * @param filename file with profiling info + * @param pn processnetwork to annotate + */ + public static void annotateProcessNetwork(String filename, + ProcessNetwork pn) { + try { + BufferedReader reader = new BufferedReader( + new FileReader(filename)); + String line; + while ((line = reader.readLine()) != null) { + StringTokenizer tokenizer = + new StringTokenizer(line, " "); + if (tokenizer.countTokens() == 2) { + continue; + } + else if (tokenizer.countTokens() <= 2) { + System.out.println("Warning: Each line in the log " + + "file should have the following form:" + + System.getProperty("line.separator") + + "processname config_name config_value" + + System.getProperty("line.separator") + + "Ignoring the non-conforming line:" + + System.getProperty("line.separator") + + line); + continue; + } + String processname = tokenizer.nextToken(); + Process process = pn.getProcess(processname); + if (process == null) { + System.out.println("Warning: Could not find process " + + processname + " in processnetwork " + + pn.getName() + ". Ignore configuration " + + "statement in file " + filename + "."); + continue; + } + ProfilingConfiguration config = + new ProfilingConfiguration(tokenizer.nextToken()); + String value = ""; + while (tokenizer.hasMoreTokens()) { + value += tokenizer.nextToken() + " "; + } + config.setValue(value.trim()); + config.setParentResource(process); + process.getProfilingList().add(config); + } + } + catch (IOException e) { + System.out.println(e); + } + } +}