使用休眠模式测量Derby速度。奇怪的值

问题描述 投票:0回答:1

我正在编写应用程序以确保使用Derby的hibernate来确保CRUD的速度。

这是我的功能:

  @Override
    public BulkTestResult testBulkInsertScenario(Long volume, Integer repeat) {
        StopWatch sw = new StopWatch();
        BulkTestResult bulkTestResult = new BulkTestResult();
        bulkTestResult.setStartDate(Instant.now());
        bulkTestResult.setCountTest(volume);
        bulkTestResult.setTestRepeat(repeat);
        familyService.clear();
       for(int i =0; i < repeat; i++) {
           List<ProjectEntity> projects = dataAnonymization.generateProjectEntityList(volume);
           runBulkTest(sw, bulkTestResult, projects, true);
       }

        bulkTestResult.setEndDate(Instant.now());
        return bulkTestResult;
    }

    private void runBulkTest(StopWatch sw, BulkTestResult bulkTestResult, List<ProjectEntity> projects, boolean resetAfter) {
        sw.reset();
        sw.start();
        familyService.save(projects);
        sw.stop();
        bulkTestResult.addMsSpeedResult(sw.getTime());
        if (resetAfter) familyService.clear();
        sw.reset();
    }

清除方法从数据库中删除所有记录。

我所遇到的问题是我作为应用程序输出收到的值。测试数据:1000条记录,重复10次

多次运行此测试获得示例速度值:

  1. 311,116,87,(...)38
  2. 32,27,30,(...)24
  3. 22,19,18,(...)21
  4. 19,18,18,(...)19

为什么会有这么多差异,为什么第一次插入总是比较慢?可能是任何硬件加速吗?

java hibernate
1个回答
0
投票

我找到了解决方案。此问题与优化有关。禁用JIT后,接收到的值是正确的。

-Djava.compiler = NONE -Xint

© www.soinside.com 2019 - 2024. All rights reserved.