package net.hyperic.sigar.test;

import net.hyperic.sigar.Sigar;
import net.hyperic.sigar.SigarNotImplementedException;
import net.hyperic.sigar.ThreadCpu;

public class TestThreadCpu extends SigarTestCase {

    public TestThreadCpu(String name) {
        super(name);
    }

    public void testCreate() throws Exception {
        Sigar sigar = new Sigar();

        ThreadCpu cpu;
        try {
            cpu = sigar.getThreadCpu();
        } catch (SigarNotImplementedException e) {
            return;
        }

        assertGtEqZeroTrace("User", cpu.getUser());

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

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

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

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

        ThreadCpu diff = sigar.getThreadCpuDiff(cpu);

        assertGtEqZeroTrace("User", diff.getUser());

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

        assertGtEqZeroTrace("Total", diff.getTotal());
    }
}

@@ -26,16 +26,51 @@
 .test;%0A%0A
+import net.hyperic.sigar.CpuTimer;%0A
 import n
@@ -703,24 +703,71 @@
 tTotal());%0A%0A
+        CpuTimer timer = new CpuTimer(sigar);%0A%0A
         for 
@@ -912,34 +912,22 @@
 f = 
-siga
+time
 r.get
-ThreadCpu
 Diff(
-cpu
 );%0A%0A

use CpuTimer