diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-11-04 19:09:51 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-11-04 19:09:51 +0100 |
commit | 8feed0b097f40faa56b89224d0bbed7400572528 (patch) | |
tree | 2991b67a114312cc39667ac6913ef37dad99e953 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp | |
parent | 3411a5c087688f4e2033247b83ce10ea1e49d837 (diff) | |
download | open-keychain-8feed0b097f40faa56b89224d0bbed7400572528.tar.gz open-keychain-8feed0b097f40faa56b89224d0bbed7400572528.tar.bz2 open-keychain-8feed0b097f40faa56b89224d0bbed7400572528.zip |
bench: add benchmark operation for testing
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java index d85652a51..73fda4f09 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyOperation.java @@ -87,6 +87,8 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp InputData inputData; OutputStream outputStream; + long startTime = System.currentTimeMillis(); + if (input.getInputBytes() != null) { byte[] inputBytes = input.getInputBytes(); inputData = new InputData(new ByteArrayInputStream(inputBytes), inputBytes.length); @@ -122,6 +124,8 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp result.setOutputBytes(outputData); } + result.mTotalTime = System.currentTimeMillis() - startTime; + Log.d(Constants.TAG, "total time taken: " + String.format("%.2f", result.mTotalTime / 1000.0) + "s"); return result; } @@ -425,10 +429,12 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp InputStream dataIn = literalData.getInputStream(); + long startDecryptTime = System.currentTimeMillis(); + long alreadyWritten = 0; long wholeSize = 0; // TODO inputData.getSize() - inputData.getStreamPosition(); int length; - byte[] buffer = new byte[1 << 16]; + byte[] buffer = new byte[8192]; byte[] firstBytes = new byte[48]; while ((length = dataIn.read(buffer)) > 0) { // Log.d(Constants.TAG, "read bytes: " + length); @@ -456,6 +462,9 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp } } + Log.d(Constants.TAG, "decrypt time taken: " + String.format("%.2f", + (System.currentTimeMillis()-startDecryptTime) / 1000.0) + "s"); + // special treatment to detect pgp mime types if (matchesPrefix(firstBytes, "-----BEGIN PGP PUBLIC KEY BLOCK-----") || matchesPrefix(firstBytes, "-----BEGIN PGP PRIVATE KEY BLOCK-----")) { |