代码拉取完成,页面将自动刷新
同步操作将从 Troy/bean-searcher 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package com.example.demo;
import cn.zhxu.bs.BeanSearcher;
import cn.zhxu.bs.MapSearcher;
import cn.zhxu.bs.util.MapUtils;
import com.example.demo.entity.Employee;
import com.example.demo.repository.EmployeeRepository;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
import java.util.Map;
@SpringBootTest
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class DemoApplicationTests {
@Autowired
private BeanSearcher beanSearcher;
@Autowired
private MapSearcher mapSearcher;
@Autowired
private EmployeeRepository employeeRepository;
@Test
@Order(1)
void warmup() {
System.out.println("热身...");
System.out.println("Bean Searcher 与 Data Jdbc 各执行 1000 次...");
long t0 = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
mapSearcher.searchAll(Employee.class, MapUtils.builder()
.field(Employee::getAge, 30)
.build());
beanSearcher.searchAll(Employee.class, MapUtils.builder()
.field(Employee::getAge, 30)
.build());
employeeRepository.findAllByAge(30);
}
long cost = System.currentTimeMillis() - t0;
System.out.println("热身完毕,耗时:" + cost + "ms");
}
@Test
@Order(2)
void testMapSearcher() {
System.out.println("MapSearcher 执行 1000 次...");
long t0 = System.currentTimeMillis();
int totalCount = 0;
for (int i = 0; i < 1000; i++) {
List<Map<String, Object>> list = mapSearcher.searchAll(Employee.class, MapUtils.builder()
.field(Employee::getAge, 30)
.build());
totalCount += list.size();
}
long cost = System.currentTimeMillis() - t0;
System.out.println("累计 Select 数量:" + totalCount);
System.out.println("MapSearcher 耗时:" + cost + "ms");
}
@Test
@Order(3)
void testDataJdbc() {
System.out.println("Data Jdbc 执行 1000 次 ...");
long t0 = System.currentTimeMillis();
int totalCount = 0;
for (int i = 0; i < 1000; i++) {
List<Employee> list = employeeRepository.findAllByAge(30);
totalCount += list.size();
}
long cost = System.currentTimeMillis() - t0;
System.out.println("累计 Select 数量:" + totalCount);
System.out.println("Data Jdbc 耗时:" + cost + "ms");
}
@Test
@Order(4)
void testBeanSearcher() {
System.out.println("BeanSearcher 执行 1000 次...");
long t0 = System.currentTimeMillis();
int totalCount = 0;
for (int i = 0; i < 1000; i++) {
List<Employee> list = beanSearcher.searchAll(Employee.class, MapUtils.builder()
.field(Employee::getAge, 30)
.build());
totalCount += list.size();
}
long cost = System.currentTimeMillis() - t0;
System.out.println("累计 Select 数量:" + totalCount);
System.out.println("BeanSearcher 耗时:" + cost + "ms");
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。