print times
This commit is contained in:
		
							parent
							
								
									eece975d12
								
							
						
					
					
						commit
						8021f4de5b
					
				@ -2,6 +2,7 @@ package net.hyperic.sigar.cmd;
 | 
			
		||||
 | 
			
		||||
import net.hyperic.sigar.Sigar;
 | 
			
		||||
import net.hyperic.sigar.SigarException;
 | 
			
		||||
import net.hyperic.sigar.ThreadCpu;
 | 
			
		||||
 | 
			
		||||
public class Time extends SigarCommandBase {
 | 
			
		||||
 | 
			
		||||
@ -26,7 +27,21 @@ public class Time extends SigarCommandBase {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void output(String[] args) throws SigarException {
 | 
			
		||||
        ThreadCpu cpu = new ThreadCpu();
 | 
			
		||||
        long start = System.currentTimeMillis();
 | 
			
		||||
 | 
			
		||||
        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()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static long toMillis(long nano) {
 | 
			
		||||
        return nano / 1000000;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void main(String[] args) throws Exception {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user