@Test(enabled = false) /** Tests of performance. "enabled = false" for the standard testing. */ public void performance() { long startTime, endTime; final int nbTest = 100; CurrencyAmount pvPayerLongApproximation = CurrencyAmount.of(CUR, 0.0); CurrencyAmount pvPayerLongNI = CurrencyAmount.of(CUR, 0.0); startTime = System.currentTimeMillis(); for (int looptest = 0; looptest < nbTest; looptest++) { pvPayerLongApproximation = METHOD_G2PP_APPROXIMATION.presentValue(SWAPTION_PAYER_LONG, BUNDLE_G2PP); } endTime = System.currentTimeMillis(); System.out.println( nbTest + " pv swaption G2++ approximation method: " + (endTime - startTime) + " ms"); // Performance note: G2++ price: 24-Aug-11: On Mac Pro 3.2 GHz Quad-Core Intel Xeon: 175 ms for // 10000 swaptions. startTime = System.currentTimeMillis(); for (int looptest = 0; looptest < nbTest; looptest++) { pvPayerLongNI = METHOD_G2PP_NI.presentValue(SWAPTION_PAYER_LONG, BUNDLE_G2PP); } endTime = System.currentTimeMillis(); System.out.println( nbTest + " pv swaption G2++ numerical integration method: " + (endTime - startTime) + " ms"); // Performance note: G2++ price: 24-Aug-11: On Mac Pro 3.2 GHz Quad-Core Intel Xeon: 1075 ms for // 100 swaptions. System.out.println("G2++ approximation - present value: " + pvPayerLongApproximation); System.out.println("G2++ numerical integration - present value: " + pvPayerLongNI); }
@Test /** Test the present value by approximation vs by numerical integration. */ public void approximationNumericalIntegration() { CurrencyAmount pvApproximation = METHOD_G2PP_APPROXIMATION.presentValue(SWAPTION_PAYER_LONG, BUNDLE_G2PP); CurrencyAmount pvNI = METHOD_G2PP_NI.presentValue(SWAPTION_PAYER_LONG, BUNDLE_G2PP); assertEquals( "Swaption physical - G2++ - present value - approximation vs Numerical integration", pvApproximation.getAmount(), pvNI.getAmount(), 2.0E+3); }