format time

This commit is contained in:
Doug MacEachern 2005-02-24 21:10:31 +00:00
parent 8021f4de5b
commit 183359750f
1 changed files with 9 additions and 5 deletions

View File

@ -33,17 +33,21 @@ public class Time extends SigarCommandBase {
this.shell.handleCommand("time " + args[0], args);
cpu.gather(this.sigar, 0);
System.out.println("real....." +
(System.currentTimeMillis() - start) / 1000);
System.out.println("user....." + toMillis(cpu.getUser()));
System.out.println("sys......" + toMillis(cpu.getSys()));
System.out.println("total...." + toMillis(cpu.getTotal()));
println("real....." +
format((System.currentTimeMillis() - start)));
println("user....." + format(toMillis(cpu.getUser())));
println("sys......" + format(toMillis(cpu.getSys())));
}
private static long toMillis(long nano) {
return nano / 1000000;
}
private static String format(long t) {
t /= 1000;
return t/60 + ":" + t%60;
}
public static void main(String[] args) throws Exception {
new Time().processCommand(args);
}