-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add optimized Wallet.getTransaction functions
- Loading branch information
1 parent
6a8ffcf
commit 112e168
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
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
44 changes: 44 additions & 0 deletions
44
core/src/test/java/org/bitcoinj/wallet/WalletBenchmarkTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.bitcoinj.wallet; | ||
|
||
import com.google.common.base.Stopwatch; | ||
import org.bitcoinj.core.Transaction; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class WalletBenchmarkTest { | ||
@Test | ||
public void getTransactionsTest() throws UnreadableWalletException, IOException { | ||
Set<Transaction> set = null; | ||
Collection<Transaction> list = null; | ||
int count = 1; | ||
try (InputStream stream = getClass().getResourceAsStream("coinjoin-testnet-big.wallet")) { | ||
WalletEx coinJoinWallet = (WalletEx) new WalletProtobufSerializer().readWallet(stream); | ||
Stopwatch watch = Stopwatch.createStarted(); | ||
for (int i = 0; i < count; ++i) | ||
set = coinJoinWallet.getTransactions(true); | ||
System.out.println("getTransactions = " + watch); | ||
} | ||
try (InputStream stream = getClass().getResourceAsStream("coinjoin-testnet-big.wallet")) { | ||
WalletEx coinJoinWallet = (WalletEx) new WalletProtobufSerializer().readWallet(stream); | ||
Stopwatch watch = Stopwatch.createStarted(); | ||
for (int i = 0; i < count; ++i) | ||
set = coinJoinWallet.getTransactionsOpt(true); | ||
System.out.println("getTransactions(optimized) = " + watch); | ||
} | ||
try (InputStream stream = getClass().getResourceAsStream("coinjoin-testnet-big.wallet")) { | ||
WalletEx coinJoinWallet = (WalletEx) new WalletProtobufSerializer().readWallet(stream); | ||
Stopwatch watch = Stopwatch.createStarted(); | ||
for (int i = 0; i < count; ++i) | ||
list = coinJoinWallet.getTransactionList(true); | ||
System.out.println("getTransactionList = " + watch); | ||
} | ||
assertEquals(set.size(), list.size()); | ||
} | ||
|
||
} |