Search in sources :

Example 1 with ExternalStateForTests

use of org.aion.zero.impl.precompiled.ExternalStateForTests in project aion by aionnetwork.

the class BenchmarkTest method benchBlake2bHash.

@Test
public void benchBlake2bHash() {
    PrecompiledTransactionContext context = new PrecompiledTransactionContext(ContractInfo.BLAKE_2B.contractAddress, origin, caller, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), txHash, txHash, blockNumber, nrgLimit, depth);
    ExternalStateForTests externalStateForTests = ExternalStateForTests.usingDefaultRepository();
    PrecompiledContract ct;
    // warm up
    for (int i = 0; i < WARMUP; i++) {
        ct = cf.getPrecompiledContract(context, externalStateForTests);
        ct.execute(txHash, context.transactionEnergy);
    }
    long t1 = System.currentTimeMillis();
    for (int i = 0; i < BENCH; i++) {
        ct = cf.getPrecompiledContract(context, externalStateForTests);
        ct.execute(txHash, context.transactionEnergy);
    }
    System.out.println("Bench blake2b: " + String.valueOf(System.currentTimeMillis() - t1) + "ms");
}
Also used : PrecompiledContract(org.aion.precompiled.type.PrecompiledContract) PrecompiledTransactionContext(org.aion.precompiled.type.PrecompiledTransactionContext) ExternalStateForTests(org.aion.zero.impl.precompiled.ExternalStateForTests) Test(org.junit.Test)

Aggregations

PrecompiledContract (org.aion.precompiled.type.PrecompiledContract)1 PrecompiledTransactionContext (org.aion.precompiled.type.PrecompiledTransactionContext)1 ExternalStateForTests (org.aion.zero.impl.precompiled.ExternalStateForTests)1 Test (org.junit.Test)1