提交 25ac2c72 authored 作者: 陈世营's avatar 陈世营

分表分库 多线程性能测试

上级 232a8c01
...@@ -31,7 +31,7 @@ public class ThreadPoolTaskConfig implements AsyncConfigurer { ...@@ -31,7 +31,7 @@ public class ThreadPoolTaskConfig implements AsyncConfigurer {
//如果池中的实际线程数小于corePoolSize,无论是否其中有空闲的线程,都会给新的任务产生新的线程 //如果池中的实际线程数小于corePoolSize,无论是否其中有空闲的线程,都会给新的任务产生新的线程
taskExecutor.setCorePoolSize(5); taskExecutor.setCorePoolSize(5);
//连接池中保留的最大连接数。Default: 15 maxPoolSize //连接池中保留的最大连接数。Default: 15 maxPoolSize
taskExecutor.setMaxPoolSize(200); taskExecutor.setMaxPoolSize(300);
//queueCapacity 线程池所使用的缓冲队列 //queueCapacity 线程池所使用的缓冲队列
taskExecutor.setQueueCapacity(500); taskExecutor.setQueueCapacity(500);
......
...@@ -29,7 +29,7 @@ public class DemoController { ...@@ -29,7 +29,7 @@ public class DemoController {
@GetMapping("purchase") @GetMapping("purchase")
public void purchase() { public void purchase() {
long startTime = System.currentTimeMillis(); //获取开始时间 long startTime = System.currentTimeMillis(); //获取开始时间
for (long i = 3920570; i <= 10000000; i++) { for (long i = 10000000; i <= 20000000; i++) {
try { try {
businessService.purchase(i); businessService.purchase(i);
} catch (Exception e) { } catch (Exception e) {
...@@ -48,7 +48,7 @@ public class DemoController { ...@@ -48,7 +48,7 @@ public class DemoController {
long startTime = System.currentTimeMillis(); //获取开始时间 long startTime = System.currentTimeMillis(); //获取开始时间
List<OrderEntity> pageList = orderService.findPage(0l, 5l); List<OrderEntity> pageList = orderService.findPage(0l, 20l);
log.info(pageList.toString()); log.info(pageList.toString());
long endTime = System.currentTimeMillis(); //获取结束时间 long endTime = System.currentTimeMillis(); //获取结束时间
...@@ -56,6 +56,21 @@ public class DemoController { ...@@ -56,6 +56,21 @@ public class DemoController {
log.info("success"); log.info("success");
} }
@GetMapping("getById")
public void getById(String orderId) {
long startTime = System.currentTimeMillis(); //获取开始时间
OrderEntity byId = orderService.getById(orderId);
log.error(byId.toString());
long endTime = System.currentTimeMillis(); //获取结束时间
log.error("程序运行时间:" + (endTime - startTime) + "ms"); //输出程序运行时间
log.info("success");
}
} }
...@@ -23,6 +23,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderEntity> impl ...@@ -23,6 +23,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderEntity> impl
@Override @Override
public List<OrderEntity> findPage(Long pageNum, Long pageSize) { public List<OrderEntity> findPage(Long pageNum, Long pageSize) {
QueryWrapper<OrderEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<OrderEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByAsc("id"); queryWrapper.orderByAsc("id");
Page<OrderEntity> page = new Page<>(pageNum, pageSize); Page<OrderEntity> page = new Page<>(pageNum, pageSize);
//分页数据 //分页数据
......
...@@ -28,7 +28,7 @@ spring: ...@@ -28,7 +28,7 @@ spring:
jdbc-url: jdbc:mysql://192.168.66.40:3321/demo_ds?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC jdbc-url: jdbc:mysql://192.168.66.40:3321/demo_ds?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
url: jdbc:mysql://192.168.66.40:3321/demo_ds?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC url: jdbc:mysql://192.168.66.40:3321/demo_ds?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
filters: stat,wall,log4j filters: stat,wall,log4j
maxActive: 20 maxActive: 40
initialSize: 1 initialSize: 1
maxWait: 60000 maxWait: 60000
minIdle: 1 minIdle: 1
...@@ -39,7 +39,7 @@ spring: ...@@ -39,7 +39,7 @@ spring:
testOnBorrow: false testOnBorrow: false
testOnReturn: false testOnReturn: false
poolPreparedStatements: true poolPreparedStatements: true
maxOpenPreparedStatements: 20 maxOpenPreparedStatements: 40
connection-properties: druid.stat.merggSql=ture;druid.stat.slowSqlMillis=5000 connection-properties: druid.stat.merggSql=ture;druid.stat.slowSqlMillis=5000
sharding: sharding:
tables: tables:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论