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();
}
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();
}
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();
}
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();
}
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);
}
Aggregations