| 1 |
package driver; |
| 2 |
|
| 3 |
import fileIO.TextFile; |
| 4 |
import shared.Tools; |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
public class ProcessSpeed2 { |
| 13 |
|
| 14 |
public static void main(String[] args){ |
| 15 |
|
| 16 |
System.out.println("#real\tuser\tsys"); |
| 17 |
|
| 18 |
String fname=args[0].replace("in=", ""); |
| 19 |
TextFile tf=new TextFile(fname); |
| 20 |
for(String line=tf.nextLine(); line!=null; line=tf.nextLine()){ |
| 21 |
if(line.startsWith("real\t")){ |
| 22 |
String time=line.split("\t")[1]; |
| 23 |
double seconds=toSeconds(time); |
| 24 |
System.out.print(Tools.format("%.3f\t", seconds)); |
| 25 |
}else if(line.startsWith("user\t")){ |
| 26 |
String time=line.split("\t")[1]; |
| 27 |
double seconds=toSeconds(time); |
| 28 |
System.out.print(Tools.format("%.3f\t", seconds)); |
| 29 |
}else if(line.startsWith("sys\t")){ |
| 30 |
String time=line.split("\t")[1]; |
| 31 |
double seconds=toSeconds(time); |
| 32 |
System.out.print(Tools.format("%.3f\n", seconds)); |
| 33 |
} |
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
} |
| 38 |
|
| 39 |
public static double toSeconds(String s){ |
| 40 |
s=s.replaceAll("s", ""); |
| 41 |
String[] split=s.split("m"); |
| 42 |
String seconds=split[1], minutes=split[0]; |
| 43 |
return 60*Double.parseDouble(minutes)+Double.parseDouble(seconds); |
| 44 |
} |
| 45 |
|
| 46 |
} |