繁体   English   中英

JBenchX eclipse很慢

[英]JBenchX eclipse very slow

我正在编写一个JBenchX方法,该方法使用flexiprovider计算CMSS签名的密钥。 我想获取我的方法createKeys的时间,但是那非常慢。 如果没有@Bench注释,则它的速度<1秒。 您能帮助您了解这里发生了什么吗?

import de.flexiprovider.api.exceptions.NoSuchAlgorithmException;
import de.flexiprovider.api.keys.KeyPair;
import de.flexiprovider.api.keys.KeyPairGenerator;
import org.jbenchx.annotations.Bench;
import org.jbenchx.annotations.ForEachInt;
import org.jbenchx.annotations.ForEachString;
import org.jbenchx.annotations.SingleRun;

public class CMSSTest {

@Bench
public Object createKeys(@ForEachString({ "CMSSwithSHA1andWinternitzOTS_1" }) String cmss) throws NoSuchAlgorithmException {
    Security.addProvider(new FlexiPQCProvider());

        //byte[] signatureBytes = null;
        KeyPairGenerator kpg = (CMSSKeyPairGenerator) Registry
                .getKeyPairGenerator(cmss);
        KeyPair keyPair = kpg.genKeyPair();
}
}

实际输出是并且仍处于活动状态。

正在初始化基准测试框架...在Linux上运行Linux最大堆= 1345847296系统基准= 11,8ns正在执行1个基准测试任务。[0] CMSSTest.createObjectArray(CMSSwithSHA1andWinternitzOTS_1)!*!** !!! ****** !! !******!****!**** !! ****** !!!! *******!******!****!* ********************************

问题似乎在于Registry.getKeyPairGenerator创建了一个新的KeyPairGenerator,并使用“ true”随机种子对其进行了初始化。 为此,系统可能必须等待足够的熵可用。 因此,您不应将此操作作为要进行基准测试的代码的一部分。

尝试这样的事情:

import java.security.Security;

import org.jbenchx.annotations.Bench;
import org.jbenchx.annotations.ForEachString;

import de.flexiprovider.api.Registry;
import de.flexiprovider.api.exceptions.NoSuchAlgorithmException;
import de.flexiprovider.api.keys.KeyPair;
import de.flexiprovider.api.keys.KeyPairGenerator;
import de.flexiprovider.pqc.FlexiPQCProvider;

public class CMSSTest {

  static {
    Security.addProvider(new FlexiPQCProvider());
  }

  private final KeyPairGenerator kpg;

  public CMSSTest(@ForEachString({"CMSSwithSHA1andWinternitzOTS_1"}) String cmss) throws NoSuchAlgorithmException {
    this.kpg = Registry.getKeyPairGenerator(cmss);
  }

  @Bench
  public Object createKeys() {
    KeyPair keyPair = kpg.genKeyPair();
    return keyPair;
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM