|
From: Pelle B. <pe...@us...> - 2004-03-24 23:23:47
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25877/src/java/org/neuclear/ledger/tests Modified Files: AbstractLedgerTest.java Log Message: Working on Hibernate Implementation. Index: AbstractLedgerTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/tests/AbstractLedgerTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractLedgerTest.java 22 Mar 2004 23:20:51 -0000 1.1 --- AbstractLedgerTest.java 24 Mar 2004 23:12:34 -0000 1.2 *************** *** 13,19 **** * $Id$ * $Log$ ! * Revision 1.1 2004/03/22 23:20:51 pelle * Working on Hibernate Implementation. * * Revision 1.2 2004/03/22 21:59:38 pelle * SimpleLedger now passes all unit tests --- 13,22 ---- * $Id$ * $Log$ ! * Revision 1.2 2004/03/24 23:12:34 pelle * Working on Hibernate Implementation. * + * Revision 1.1 2004/03/22 23:20:51 pelle + * Working on Hibernate Implementation. + * <p/> * Revision 1.2 2004/03/22 21:59:38 pelle * SimpleLedger now passes all unit tests *************** *** 135,138 **** --- 138,142 ---- static final String BOB = "bob"; static final String ALICE = "alice"; + static final String CAROL = "carol"; *************** *** 193,197 **** try { ledger.verifiedTransfer(ALICE, BOB, ledger.getAvailableBalance(ALICE) + 10, "To much"); ! assertTrue("InssuficientFundsException should have been thrown", false); } catch (InsufficientFundsException e) { ; --- 197,201 ---- try { ledger.verifiedTransfer(ALICE, BOB, ledger.getAvailableBalance(ALICE) + 10, "To much"); ! assertTrue("InssuficientFundsException should have been thrown. Attempted to transfer: " + (ledger.getAvailableBalance(ALICE) + 10), false); } catch (InsufficientFundsException e) { ; *************** *** 204,216 **** public final void testMultiTransfer() throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { ! final double bobBalance = ledger.getBalance(BOB); int cumulative = 0; for (int i = 0; i < 100; i++) { ! ledger.transfer("req" + i + System.currentTimeMillis(), "x" + i + System.currentTimeMillis(), "Issuer", "bob", i, "fund it"); cumulative += i; ! assertEquals("BOB BALANCE", bobBalance + cumulative, ledger.getBalance(BOB), 0); ! assertEquals("BOB AVAILABLE BALANCE", ledger.getBalance(BOB), ledger.getAvailableBalance(BOB), 0); } ! System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } --- 208,220 ---- public final void testMultiTransfer() throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { ! final double bobBalance = ledger.getBalance(CAROL); int cumulative = 0; for (int i = 0; i < 100; i++) { ! ledger.transfer("req" + i + System.currentTimeMillis(), "x" + i + System.currentTimeMillis(), "Issuer", CAROL, i, "fund it"); cumulative += i; ! assertEquals("BOB BALANCE", bobBalance + cumulative, ledger.getBalance(CAROL), 0); ! assertEquals("BOB AVAILABLE BALANCE", ledger.getBalance(CAROL), ledger.getAvailableBalance(CAROL), 0); } ! System.out.println("Bob's Balance: " + ledger.getBalance(CAROL)); } *************** *** 327,330 **** --- 331,352 ---- } + public final void testNaiveBenchmark() throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { + final int iterations = 1000; + final double amount = 50; + final String book = "benchbook-" + System.currentTimeMillis(); + final double fundamount = amount * (iterations + 1); + ledger.transfer("fund", book, fundamount, "fund the benchmark"); + System.out.println("Start Balance: " + ledger.getBalance(book)); + assertEquals(fundamount, ledger.getAvailableBalance(book), 0); + + long start = System.currentTimeMillis(); + for (int i = 0; i < iterations; i++) { + ledger.verifiedTransfer(book, "fund", amount, "transaction" + i); + } + final long duration = System.currentTimeMillis() - start; + System.out.println("" + iterations + " iterations took " + duration + " ms"); + System.out.println("Each iteration took " + duration / iterations + " ms"); + assertEquals(amount, ledger.getAvailableBalance(book), 0); + } protected Ledger ledger; |