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