allow int arg to specific number of iterations
This commit is contained in:
parent
a3e6120bc7
commit
2246f7e747
|
@ -30,10 +30,25 @@ public class Time extends SigarCommandBase {
|
||||||
//turn off paging.
|
//turn off paging.
|
||||||
this.shell.setInteractive(false);
|
this.shell.setInteractive(false);
|
||||||
CpuTimer cpu = new CpuTimer(this.sigar);
|
CpuTimer cpu = new CpuTimer(this.sigar);
|
||||||
|
|
||||||
|
int num;
|
||||||
|
|
||||||
|
if (Character.isDigit(args[0].charAt(0))) {
|
||||||
|
num = Integer.parseInt(args[0]);
|
||||||
|
String[] xargs = new String[args.length-1];
|
||||||
|
System.arraycopy(args, 1, xargs, 0, xargs.length);
|
||||||
|
args = xargs;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
num = 1;
|
||||||
|
}
|
||||||
|
|
||||||
cpu.start();
|
cpu.start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
for (int i=0; i<num; i++) {
|
||||||
this.shell.handleCommand("time " + args[0], args);
|
this.shell.handleCommand("time " + args[0], args);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.shell.setInteractive(isInteractive);
|
this.shell.setInteractive(isInteractive);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue