1 /* $Id: VSPLogFileProfiler.java 1 2010-02-24 13:03:05Z haidw $ */
\r
2 package dol.helper.profiler;
\r
4 import java.io.BufferedReader;
\r
5 import java.io.FileReader;
\r
6 import java.io.IOException;
\r
7 import java.util.StringTokenizer;
\r
9 import dol.datamodel.pn.Process;
\r
10 import dol.datamodel.pn.ProcessNetwork;
\r
11 import dol.datamodel.pn.ProfilingConfiguration;
\r
14 * Class for parsing a file with profiling info and annotate it to a
\r
17 public class VSPLogFileProfiler {
\r
20 * Parse the given file and annotate the data to the given process
\r
23 * @param filename file with profiling info
\r
24 * @param pn processnetwork to annotate
\r
26 public static void annotateProcessNetwork(String filename,
\r
27 ProcessNetwork pn) {
\r
29 BufferedReader reader = new BufferedReader(
\r
30 new FileReader(filename));
\r
32 while ((line = reader.readLine()) != null) {
\r
33 StringTokenizer tokenizer =
\r
34 new StringTokenizer(line, " ");
\r
35 if (tokenizer.countTokens() == 2) {
\r
38 else if (tokenizer.countTokens() <= 2) {
\r
39 System.out.println("Warning: Each line in the log "
\r
40 + "file should have the following form:"
\r
41 + System.getProperty("line.separator")
\r
42 + "processname config_name config_value"
\r
43 + System.getProperty("line.separator")
\r
44 + "Ignoring the non-conforming line:"
\r
45 + System.getProperty("line.separator")
\r
49 String processname = tokenizer.nextToken();
\r
50 Process process = pn.getProcess(processname);
\r
51 if (process == null) {
\r
52 System.out.println("Warning: Could not find process "
\r
53 + processname + " in processnetwork "
\r
54 + pn.getName() + ". Ignore configuration "
\r
55 + "statement in file " + filename + ".");
\r
58 ProfilingConfiguration config =
\r
59 new ProfilingConfiguration(tokenizer.nextToken());
\r
61 while (tokenizer.hasMoreTokens()) {
\r
62 value += tokenizer.nextToken() + " ";
\r
64 config.setValue(value.trim());
\r
65 config.setParentResource(process);
\r
66 process.getProfilingList().add(config);
\r
69 catch (IOException e) {
\r
70 System.out.println(e);
\r