Java JBenchX日食非常慢

Java JBenchX日食非常慢,java,eclipse,Java,Eclipse,我正在编写一个JBenchX方法,该方法使用flexiprovider计算CMSS签名的密钥。我想为我的方法createKeys获取计时,但这非常慢。没有注释@工作台太快

我正在编写一个JBenchX方法,该方法使用flexiprovider计算CMSS签名的密钥。我想为我的方法createKeys获取计时,但这非常慢。没有注释@工作台太快<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上运行 最大堆=1345847296系统基准=11,8ns 执行1项基准测试任务。。
[0]CMSSTest.createObjectArray(带有HA1和WinterNitZots_1的CMSSs)!**************!!***********************************************!!******************************************************************

问题似乎在于
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;
  }
}