Created
March 22, 2019 06:48
-
-
Save liu246542/294a2f055e9a877de68b5c80873f44dc to your computer and use it in GitHub Desktop.
论文里面测试代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from charm.toolbox.pairinggroup import PairingGroup,ZR,G1,G2,GT,pair | |
def test_pair(): | |
trials = 10 | |
group = PairingGroup("SS512") | |
h = group.random(G1) | |
i = group.random(G2) | |
assert group.InitBenchmark(), "failed to initialize benchmark" | |
group.StartBenchmark(["CpuTime","RealTime","Pair"]) | |
for a in range(trials): | |
n = pair(h, i) | |
group.EndBenchmark() | |
msmtDict = group.GetGeneralBenchmarks() | |
return msmtDict['CpuTime']/trials | |
T = [] | |
for i in range(1000): | |
T.append(test_pair()) | |
print(sum(T)/len(T)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment