Search in sources :

Example 1 with Tick

use of mysh.util.Tick in project mlib by myshzzx.

the class CaptchaTest method benchmark.

@Test
public void benchmark() throws Exception {
    int n;
    int count = 3_000;
    BufferedImage bi = null;
    Tick tick = Tick.tick("captcha");
    n = count;
    tick.reset();
    while (n-- > 0) bi = captcha.renderWord("faiej");
    tick.nipAndPrint("renderWord");
    n = count;
    tick.reset();
    while (n-- > 0) captcha.makeNoise(bi, .1f, .1f, .9f, .9f);
    tick.nipAndPrint("makeNoise");
    n = count;
    tick.reset();
    while (n-- > 0) captcha.getDistortedImage(bi);
    tick.nipAndPrint("getDistortedImage");
    n = count;
    tick.reset();
    while (n-- > 0) captcha.addBackground(bi);
    tick.nipAndPrint("addBackground");
    tick.printNipsTotal();
}
Also used : Tick(mysh.util.Tick) BufferedImage(java.awt.image.BufferedImage) Test(org.junit.Test)

Example 2 with Tick

use of mysh.util.Tick in project mlib by myshzzx.

the class ReflectionTest method reflectionMethodCall.

public void reflectionMethodCall(Method f) throws IllegalAccessException, InvocationTargetException {
    f.setAccessible(true);
    int n;
    T t = new T();
    Tick tick = Tick.tick(f.getName());
    n = INVOKE_TIMES;
    t.v = 0;
    while (n-- > 0) f.invoke(t);
    tick.nipAndPrint();
    tick.reset();
    n = INVOKE_TIMES;
    t.v = 0;
    while (n-- > 0) f.invoke(t);
    tick.nipAndPrint();
}
Also used : Tick(mysh.util.Tick)

Example 3 with Tick

use of mysh.util.Tick in project mlib by myshzzx.

the class ReflectionTest method directPublicCall.

@Test
public void directPublicCall() {
    int n;
    T t = new T();
    Tick tick = Tick.tick("public");
    n = INVOKE_TIMES;
    t.v = 0;
    while (n-- > 0) t.f2();
    tick.nipAndPrint();
    tick.reset();
    n = INVOKE_TIMES;
    t.v = 0;
    while (n-- > 0) t.f2();
    tick.nipAndPrint();
}
Also used : Tick(mysh.util.Tick) Test(org.junit.Test)

Example 4 with Tick

use of mysh.util.Tick in project mlib by myshzzx.

the class SerializationPerformance method test.

public void test(TI ti, Serializable o) throws Exception {
    int times = 100_000;
    ti.s(o, times);
    ti.ds(o, times);
    System.out.println("byte size = " + tb.length + " : " + ti.getClass().getSimpleName());
    System.gc();
    Thread.sleep(3000);
    times = 1_000_000;
    Tick tick = Tick.tick(ti.getClass().getSimpleName());
    ti.s(o, times);
    tick.nipAndPrint("s");
    System.gc();
    Thread.sleep(3000);
    tick.reset();
    ti.ds(o, times);
    tick.nipAndPrint("ds");
    tick.printNipsTotal();
}
Also used : Tick(mysh.util.Tick)

Example 5 with Tick

use of mysh.util.Tick in project mlib by myshzzx.

the class PorkerCheck method main.

public static void main(String[] args) throws IOException {
    int c = 0;
    List<String> lines = Files.readAllLines(Paths.get("l:/p054_poker.txt"));
    Tick tick = Tick.tick();
    for (String line : lines) {
        if (p1win(line))
            c++;
    }
    System.out.println();
    tick.nipAndPrint();
    System.out.println(c);
}
Also used : Tick(mysh.util.Tick)

Aggregations

Tick (mysh.util.Tick)8 Test (org.junit.Test)3 MethodSignature (org.aspectj.lang.reflect.MethodSignature)2 BufferedImage (java.awt.image.BufferedImage)1 Around (org.aspectj.lang.annotation.Around)1