From bb2f43c3172cf76a2b93575bd5698c5c9899ed26 Mon Sep 17 00:00:00 2001 From: Redkale <22250530@qq.com> Date: Fri, 17 Mar 2017 09:26:44 +0800 Subject: [PATCH] --- test/org/redkale/test/sncp/SncpTestService.java | 5 +++++ test/org/redkale/test/source/CacheTestBean.java | 4 ++-- test/org/redkale/test/source/TestSourceCache.java | 8 ++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/org/redkale/test/sncp/SncpTestService.java b/test/org/redkale/test/sncp/SncpTestService.java index 9c6f835ca..9713b1c73 100644 --- a/test/org/redkale/test/sncp/SncpTestService.java +++ b/test/org/redkale/test/sncp/SncpTestService.java @@ -61,6 +61,11 @@ public class SncpTestService implements SncpTestIService { return "result: " + bean; } + public void queryResult(AsyncHandler handler, @RpcAttachment SncpTestBean bean) { + System.out.println(Thread.currentThread().getName() + " handler 运行了queryResult方法"); + if (handler != null) handler.completed("result: " + bean, bean); + } + @RpcMultiRun public String updateBean(@RpcCall(CallAttribute.class) SncpTestBean bean) { bean.setId(System.currentTimeMillis()); diff --git a/test/org/redkale/test/source/CacheTestBean.java b/test/org/redkale/test/source/CacheTestBean.java index f32c09ab2..34c31c717 100644 --- a/test/org/redkale/test/source/CacheTestBean.java +++ b/test/org/redkale/test/source/CacheTestBean.java @@ -36,10 +36,10 @@ public class CacheTestBean { Attribute nameattr = Attribute.create(CacheTestBean.class, "name"); Attribute priceattr = Attribute.create(CacheTestBean.class, "price"); BiFunction fullloader = (s, z) -> list; - Method method = EntityInfo.class.getDeclaredMethod("load", Class.class, int.class, boolean.class, Properties.class, + Method method = EntityInfo.class.getDeclaredMethod("load", Class.class, boolean.class, Properties.class, DataSource.class, BiFunction.class); method.setAccessible(true); - final EntityInfo info = (EntityInfo) method.invoke(null, CacheTestBean.class, 0, true, new Properties(), null, fullloader); + final EntityInfo info = (EntityInfo) method.invoke(null, CacheTestBean.class, true, new Properties(), null, fullloader); EntityCache cache = new EntityCache(info, null); cache.fullLoad(); diff --git a/test/org/redkale/test/source/TestSourceCache.java b/test/org/redkale/test/source/TestSourceCache.java index 3bfa9470d..c87b51550 100644 --- a/test/org/redkale/test/source/TestSourceCache.java +++ b/test/org/redkale/test/source/TestSourceCache.java @@ -44,10 +44,10 @@ public class TestSourceCache { public static void main(String[] args) throws Exception { final BiFunction fullloader = (DataSource t, Class u) -> null; - Method method = EntityInfo.class.getDeclaredMethod("load", Class.class, int.class, boolean.class, Properties.class, + Method method = EntityInfo.class.getDeclaredMethod("load", Class.class, boolean.class, Properties.class, DataSource.class, BiFunction.class); - method.setAccessible(true); - final EntityInfo info = (EntityInfo) method.invoke(null, TestEntity.class, 0, false, new Properties(), null, fullloader); + method.setAccessible(true); + final EntityInfo info = (EntityInfo) method.invoke(null, TestEntity.class, false, new Properties(), null, fullloader); TestEntity[] entitys = new TestEntity[10_0000]; for (int i = 0; i < entitys.length; i++) { entitys[i] = new TestEntity(i + 1, "用户_" + (i + 1)); @@ -86,7 +86,7 @@ public class TestSourceCache { } cdl.await(); e = System.currentTimeMillis() - s; - System.out.println("十万条数据中查询一页记录耗时: " + e / 1000.0 + " 秒 " + sheet); // CopyOnWriteArrayList 0.798 ConcurrentLinkedQueue 1.063 + System.out.println("十万条数据中100并发查询一页循环10次记录耗时: " + e / 1000.0 + " 秒 " + sheet); // CopyOnWriteArrayList 0.798 ConcurrentLinkedQueue 1.063 } @VirtualEntity