Search in sources :

Example 6 with MeasurementRecorder

use of org.spf4j.perf.MeasurementRecorder in project spf4j by zolyfarkas.

the class RecorderFactoryTest method testRecorderFactory.

@Test
public void testRecorderFactory() throws InterruptedException, IOException, InstanceNotFoundException, MBeanException, AttributeNotFoundException, ReflectionException {
    MeasurementRecorder rec = RecorderFactory.createScalableQuantizedRecorder(RecorderFactoryTest.class, "ms", 100000000, 10, 0, 6, 10);
    rec.record(1);
    int sum = 1;
    for (int i = 0; i < 10; i++) {
        rec.record(i);
        sum += i;
    }
    String ret3 = (String) Client.getAttribute("service:jmx:rmi:///jndi/rmi://:9999/jmxrmi", "org.spf4j.perf.recorders", "class_" + RecorderFactoryTest.class.getName(), "measurementsAsString");
    Assert.assertThat(ret3, Matchers.containsString(sum + "," + 11));
    rec.close();
}
Also used : MeasurementRecorder(org.spf4j.perf.MeasurementRecorder) Test(org.junit.Test)

Example 7 with MeasurementRecorder

use of org.spf4j.perf.MeasurementRecorder in project spf4j by zolyfarkas.

the class RecorderFactoryTest method testRecorderFactory2.

@Test
public void testRecorderFactory2() throws InterruptedException, IOException, InstanceNotFoundException, MBeanException, AttributeNotFoundException, ReflectionException {
    MeasurementRecorder rec = RecorderFactory.createScalableQuantizedRecorder(RecorderFactoryTest.class, "ms", 100000000, 10, 0, 6, 10);
    CompositeData ret3 = (CompositeData) Client.getAttribute("service:jmx:rmi:///jndi/rmi://:9999/jmxrmi", "org.spf4j.perf.recorders", "class_" + RecorderFactoryTest.class.getName(), "measurements");
    Assert.assertNull(ret3);
    rec.close();
}
Also used : CompositeData(javax.management.openmbean.CompositeData) MeasurementRecorder(org.spf4j.perf.MeasurementRecorder) Test(org.junit.Test)

Example 8 with MeasurementRecorder

use of org.spf4j.perf.MeasurementRecorder in project spf4j by zolyfarkas.

the class RecorderFactoryTest method testRecorderFactoryDyna.

@Test
public void testRecorderFactoryDyna() throws InterruptedException, IOException, InstanceNotFoundException, MBeanException, AttributeNotFoundException, ReflectionException {
    MeasurementRecorderSource rec = RecorderFactory.createScalableQuantizedRecorderSource(RsTest.class, "ms", 100000000, 10, 0, 6, 10);
    MeasurementRecorder recorder = rec.getRecorder("test");
    recorder.record(1);
    int sum = 1;
    for (int i = 0; i < 10; i++) {
        recorder.record(i);
        sum += i;
    }
    String ret3 = (String) Client.getAttribute("service:jmx:rmi:///jndi/rmi://:9999/jmxrmi", "org.spf4j.perf.recorders", "class_" + RecorderFactoryTest.class.getName() + "_RsTest", "measurementsAsString");
    Assert.assertThat(ret3, Matchers.containsString("test," + sum + "," + 11));
    rec.close();
}
Also used : MeasurementRecorder(org.spf4j.perf.MeasurementRecorder) MeasurementRecorderSource(org.spf4j.perf.MeasurementRecorderSource) Test(org.junit.Test)

Aggregations

MeasurementRecorder (org.spf4j.perf.MeasurementRecorder)8 Test (org.junit.Test)5 AbstractRunnable (org.spf4j.base.AbstractRunnable)3 JmxExport (org.spf4j.jmx.JmxExport)3 MeasurementRecorderSource (org.spf4j.perf.MeasurementRecorderSource)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 TObjectLongMap (gnu.trove.map.TObjectLongMap)1 TObjectLongHashMap (gnu.trove.map.hash.TObjectLongHashMap)1 CompositeData (javax.management.openmbean.CompositeData)1