[英]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.