diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-11-04 20:24:06 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-11-04 20:24:06 +0100 |
commit | a4518c43c2fdff3852668242978a8b9739447d0b (patch) | |
tree | e34dc9d1237705b1c599d5f13db6467bcc51418f /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BenchmarkOperation.java | |
parent | 8feed0b097f40faa56b89224d0bbed7400572528 (diff) | |
download | open-keychain-a4518c43c2fdff3852668242978a8b9739447d0b.tar.gz open-keychain-a4518c43c2fdff3852668242978a8b9739447d0b.tar.bz2 open-keychain-a4518c43c2fdff3852668242978a8b9739447d0b.zip |
bench: simple working benchmark
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BenchmarkOperation.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BenchmarkOperation.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BenchmarkOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BenchmarkOperation.java index 75ad4094c..6f3077fd4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BenchmarkOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BenchmarkOperation.java @@ -27,6 +27,7 @@ import android.support.annotation.NonNull; import org.sufficientlysecure.keychain.operations.results.BenchmarkResult; import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult; +import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.operations.results.SignEncryptResult; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel; @@ -54,9 +55,10 @@ public class BenchmarkOperation extends BaseOperation<BenchmarkInputParcel> { public BenchmarkResult execute(BenchmarkInputParcel consolidateInputParcel, CryptoInputParcel cryptoInputParcel) { OperationLog log = new OperationLog(); + log.add(LogType.MSG_BENCH, 0); // random data - byte[] buf = new byte[1024]; + byte[] buf = new byte[1024*1024*5]; new Random().nextBytes(buf); Passphrase passphrase = new Passphrase("a"); @@ -66,24 +68,30 @@ public class BenchmarkOperation extends BaseOperation<BenchmarkInputParcel> { { SignEncryptOperation op = new SignEncryptOperation(mContext, mProviderHelper, - new ProgressScaler(mProgressable, 0, 10, 100), mCancelled); + new ProgressScaler(mProgressable, 0, 50, 100), mCancelled); SignEncryptParcel input = new SignEncryptParcel(); input.setSymmetricPassphrase(passphrase); input.setBytes(buf); encryptResult = op.execute(input, new CryptoInputParcel()); } + log.add(encryptResult, 1); + log.add(LogType.MSG_BENCH_ENC_TIME, 1, + String.format("%.2f", encryptResult.getResults().get(0).mOperationTime / 1000.0)); // decrypt DecryptVerifyResult decryptResult; { PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(mContext, mProviderHelper, - new ProgressScaler(mProgressable, 0, 10, 100)); + new ProgressScaler(mProgressable, 50, 100, 100)); PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(encryptResult.getResultBytes()); input.setAllowSymmetricDecryption(true); decryptResult = op.execute(input, new CryptoInputParcel(passphrase)); } + log.add(decryptResult, 1); + log.add(LogType.MSG_BENCH_DEC_TIME, 1, String.format("%.2f", decryptResult.mOperationTime / 1000.0)); + log.add(LogType.MSG_BENCH_SUCCESS, 0); return new BenchmarkResult(BenchmarkResult.RESULT_OK, log); } |