Package org.hyperic.sigar

Examples of org.hyperic.sigar.CpuTimer


    public void output(String[] args) throws SigarException {
        boolean isInteractive = this.shell.isInteractive();
        //turn off paging.
        this.shell.setInteractive(false);
        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();

        try {
            for (int i=0; i<num; i++) {
                this.shell.handleCommand("time " + args[0], args);
            }
        } finally {
            this.shell.setInteractive(isInteractive);
        }

        cpu.stop();
        cpu.list(this.out);
    }
View Full Code Here


        assertGtEqZeroTrace("Sys", cpu.getSys());

        assertGtEqZeroTrace("Total", cpu.getTotal());

        CpuTimer timer = new CpuTimer(sigar);
        timer.start();

        for (int i=0; i<1000000; i++) {
            System.getProperty("java.home");
        }

        String sleepTime =
            System.getProperty("sigar.testThreadCpu.sleep");
        if (sleepTime != null) {
            Thread.sleep(Integer.parseInt(sleepTime) * 1000);
        }
        timer.stop();

        traceln("\nUsage...\n");

        assertGtEqZeroTrace("User", timer.getCpuUser());

        assertGtEqZeroTrace("Sys", timer.getCpuSys());

        assertGtEqZeroTrace("Total", timer.getCpuTotal());

        assertGtEqZeroTrace("Real Time", timer.getTotalTime());

        traceln("Cpu Percent=" + CpuPerc.format(timer.getCpuUsage()));
    }
View Full Code Here

        assertGtEqZeroTrace("Sys", cpu.getSys());

        assertGtEqZeroTrace("Total", cpu.getTotal());

        CpuTimer timer = new CpuTimer(sigar);
        timer.start();

        for (int i=0; i<1000000; i++) {
            System.getProperty("java.home");
        }

        String sleepTime =
            System.getProperty("sigar.testThreadCpu.sleep");
        if (sleepTime != null) {
            Thread.sleep(Integer.parseInt(sleepTime) * 1000);
        }
        timer.stop();

        traceln("\nUsage...\n");

        assertGtEqZeroTrace("User", timer.getCpuUser());

        assertGtEqZeroTrace("Sys", timer.getCpuSys());

        assertGtEqZeroTrace("Total", timer.getCpuTotal());

        assertGtEqZeroTrace("Real Time", timer.getTotalTime());

        traceln("Cpu Percent=" + CpuPerc.format(timer.getCpuUsage()));
    }
View Full Code Here

    public void output(String[] args) throws SigarException {
        boolean isInteractive = this.shell.isInteractive();
        //turn off paging.
        this.shell.setInteractive(false);
        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();

        try {
            for (int i=0; i<num; i++) {
                this.shell.handleCommand("time " + args[0], args);
            }
        } finally {
            this.shell.setInteractive(isInteractive);
        }

        cpu.stop();
        cpu.list(this.out);
    }
View Full Code Here

TOP

Related Classes of org.hyperic.sigar.CpuTimer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.