Package com.opengamma.util.monitor

Examples of com.opengamma.util.monitor.OperationTimer


    final double[] start = new double[] {0.03, 0.4, 0.1, 0.2 };
    for (int i = 0; i < _hotspotWarmupCycles; i++) {
      fitter.getFitResult(OPTIONS, DATA, ERRORS, start, fixed);
    }
    if (_benchmarkCycles > 0) {
      final OperationTimer timer = new OperationTimer(_logger, "processing {} cycles fitting with {}", _benchmarkCycles, name);
      for (int i = 0; i < _benchmarkCycles; i++) {
        fitter.getFitResult(OPTIONS, DATA, ERRORS, start, fixed);
      }
      timer.finished();
    }
  }
View Full Code Here


    for (int i = 0; i < warmups; i++) {
      TESTER.testBlackScholesEquationUniformGrid(SOLVER, timeSteps, priceSteps, lowerMoneyness, upperMoneyness, volTol, priceTol, deltaTol, gammaTol, print);
    }
    if (benchmarkCycles > 0) {
      final OperationTimer timer = new OperationTimer(logger, "processing {} cycles on testBlackScholesEquation2", benchmarkCycles);
      for (int i = 0; i < benchmarkCycles; i++) {
        TESTER.testBlackScholesEquationUniformGrid(SOLVER, timeSteps, priceSteps, lowerMoneyness, upperMoneyness, volTol, priceTol, deltaTol, gammaTol, print);
      }
      timer.finished();
    }
  }
View Full Code Here

      // 20 points, 10 curves
      writeOneSimulationSeriesDate(simulationSource, simulationSeriesDate, (20*10));
      simulationSeriesDate = simulationSeriesDate.minusDays(1);
    }
   
    OperationTimer timer = new OperationTimer(s_logger, "Loading TS");
    Random random = new Random();
    for (int i = 0; i < 1000; i++) {
      LocalDate seriesDate = simulationSeriesDate.minusDays(random.nextInt(numDaysHistory));
      UniqueId id = generateId(random.nextInt(1260));
      simulationSource.setCurrentSimulationExecutionDate(seriesDate);
      simulationSource.getHistoricalTimeSeries(id, null, false, null, false);
    }
    System.out.println("Loading 1000 TS took " + timer.finished());
  }
View Full Code Here

    }
    System.out.println("Loading 1000 TS took " + timer.finished());
  }

  private void writeOneSimulationSeriesDate(RedisSimulationSeriesSource simulationSource, LocalDate simulationSeriesDate, int nSeries) {
    OperationTimer timer = new OperationTimer(s_logger, "Storing many time series");
   
    // 20 points, 10 curves
    for (int i = 0; i < nSeries; i++) {
      performanceWriteOneSeries(simulationSource, generateId(i), simulationSeriesDate);
    }
   
    System.out.println("Writing " + nSeries + " series took " + timer.finished());
  }
View Full Code Here

    for (int i = 0; i < warmups; i++) {
      mc.solve(grid, 0.5);
    }
    if (benchmarkCycles > 0) {
      final OperationTimer timer = new OperationTimer(logger, "processing {} cycles on timeTest", benchmarkCycles);
      for (int i = 0; i < benchmarkCycles; i++) {
        mc.solve(grid, 0.5);
      }
      timer.finished();
    }

  }
View Full Code Here

    final double bump = 0.001;
    final double[][][] sensiBlackFD = new double[NB_EXPIRY][NB_MATURITY][NB_STRIKE];

    final double[] pv = new double[NB_INS];

    final OperationTimer timer = new OperationTimer(_logger, "Calibrating {}x{}x{}x{} SABR and computing Black sensitivities for {} instruments", NB_INS, NB_EXPIRY, NB_MATURITY, NB_STRIKE, NB_INS);
    for (int loopins = 0; loopins < NB_INS; loopins++) {
      pv[loopins] = METHOD_SWAPTION_SABR.presentValue(INSTRUMENTS[loopins], sabrBundle).getAmount();
      final PresentValueSABRSensitivityDataBundle sensiPoint = INSTRUMENTS[loopins].accept(PVSSC_SABR, sabrBundle);
      final PresentValueSABRSensitivityDataBundle sensiNode = SABRSensitivityNodeCalculator.calculateNodeSensitivities(sensiPoint, sabrParameters);
      final Map<DoublesPair, DoubleMatrix1D> sensiBlack = BlackSensitivityFromSABRSensitivityCalculator.blackSensitivity(sensiNode, inverseJacobianMap);
      for (int loopexpiry = 0; loopexpiry < NB_EXPIRY; loopexpiry++) {
        for (int loopmat = 0; loopmat < NB_MATURITY; loopmat++) {
          for (int loopstr = 0; loopstr < NB_STRIKE; loopstr++) {
            final double[][][] bumpedVol = bump(loopexpiry, loopmat, loopstr, bump);
            final ObjectsPair<SABRInterestRateParameters, HashMap<DoublesPair, DoubleMatrix2D>> bumpedResult = calibration(bumpedVol);
            final SABRInterestRateDataBundle bumpedSabrBundle = new SABRInterestRateDataBundle(bumpedResult.getFirst(), CURVES);
            final double bumpedPv = METHOD_SWAPTION_SABR.presentValue(INSTRUMENTS[loopins], bumpedSabrBundle).getAmount();
            sensiBlackFD[loopexpiry][loopmat][loopstr] = (bumpedPv - pv[loopins]) / bump;
            final double sensiCalc = sensiBlack.get(DoublesPair.of(EXPIRY_TIME[loopexpiry], MATURITY_TIME[loopmat])).getEntry(loopstr);
            if (loopins != 0 && loopexpiry != 1 && loopmat != 2 && loopstr != 0) { // The first point has a larger error wrt FD.
              assertTrue("Black Node Sensitivity: FD [" + loopexpiry + ", " + loopmat + ", " + loopstr + "]",
                  Math.abs(sensiBlackFD[loopexpiry][loopmat][loopstr] - sensiCalc) < 25.0 || Math.abs(sensiBlackFD[loopexpiry][loopmat][loopstr] / sensiCalc - 1) < 0.05);
            }
          } // end loopstr
        } // end loopmat
      } // end loopexpiry
    } // end loopins
    timer.finished();
  }
View Full Code Here

  public Map<ExternalId, Map<String, String>> getLastKnownValues() {
    s_logger.debug("Reading Redis LKV values for normalizationRuleSetId:{} globalPrefix:{} dataFieldBlackList:{} schemeBlackList:{}",
        new Object[] {getNormalizationRuleSetId(), getGlobalPrefix(), _dataFieldBlackList.keySet(), _schemeBlackList.keySet()});
    List<ExternalId> allSecurities = getAllSecurities();
    OperationTimer timer = new OperationTimer(s_logger, "Reading LKV for {} securities", allSecurities.size());
    Map<ExternalId, Map<String, String>> result = getLastKnownValues(allSecurities);
    timer.finished();
    return result;
  }
View Full Code Here

    remoteServerTool.initAndRun(args, ToolContext.class);
  }
 
  protected void loadHistoricalTimeSeries(final HistoricalTimeSeriesMaster htsMaster) {
    s_logger.info("loading timeseries");
    final OperationTimer timer = new OperationTimer(s_logger, "Loading time series");
    AbstractTool<ToolContext> remoteServerTool = new AbstractTool<ToolContext>() {
     
      @Override
      protected void doRun() throws Exception {
        final HistoricalTimeSeriesMaster remoteHtsMaster = getToolContext().getHistoricalTimeSeriesMaster();
        for (final HistoricalTimeSeriesInfoDocument infoDoc : HistoricalTimeSeriesInfoSearchIterator.iterable(remoteHtsMaster, new HistoricalTimeSeriesInfoSearchRequest())) {
          ObjectId timeSeriesObjectId = infoDoc.getInfo().getTimeSeriesObjectId();
          final ManageableHistoricalTimeSeries timeSeries = remoteHtsMaster.getTimeSeries(timeSeriesObjectId, VersionCorrection.LATEST);
          _tsList.add(infoDoc);
          _completionService.submit(new Callable<UniqueId>() {
           
            @Override
            public UniqueId call() throws Exception {
              try {
                ManageableHistoricalTimeSeriesInfo added = htsMaster.add(infoDoc).getInfo();
                htsMaster.updateTimeSeriesDataPoints(added.getTimeSeriesObjectId(), timeSeries.getTimeSeries());
                return added.getUniqueId();
              } catch (Exception ex) {
                ex.printStackTrace();
                return null;
              }
            }
          });
        }
      }
    };
    String[] args = {"-c", getServerUrl()};
    remoteServerTool.initAndRun(args, ToolContext.class);
    for (int i = 0; i < _tsList.size(); i++) {
      try {
        _completionService.take();
      } catch (Exception ex) {
        throw new OpenGammaRuntimeException("Error writing TS to remote master", ex);
      }
    }
    timer.finished();
  }
View Full Code Here

  public File getInputFile() {
    return _inputFile;
  }

  public Map<ExternalId, Map<String, Double>> getLastKnownValues() {
    OperationTimer timer = new OperationTimer(s_logger, "Reading LKV from disk");
    FileInputStream fis = null;
    try {
      fis = new FileInputStream(getInputFile());
    } catch (FileNotFoundException ex) {
      throw new OpenGammaRuntimeException("Error opening file " + getInputFile().getAbsolutePath(), ex);
    }
    Map<ExternalId, Map<String, Double>> ticks = Maps.newHashMap();
    FudgeMsgReader reader = s_fudgeContext.createMessageReader(fis);
    try {
      while (reader.hasNext()) {
        FudgeMsg message = reader.nextMessage();
        ExternalId securityId = ExternalId.parse(message.getString(RedisLKVFileWriter.SECURITY));
        if (_schemeBlackList.containsKey(securityId.getScheme().getName())) {
          continue;
        }
        FudgeMsg ticksMsg = message.getMessage(RedisLKVFileWriter.TICKS);
        Map<String, Double> secTicks = Maps.newHashMap();
        for (String fieldName : ticksMsg.getAllFieldNames()) {
          if (_dataFieldBlackList.containsKey(fieldName.toUpperCase())) {
            continue;
          }
          secTicks.put(fieldName, ticksMsg.getDouble(fieldName));
        }
        ticks.put(securityId, secTicks);
      }
    } finally {
      IOUtils.closeQuietly(fis);
    }
    timer.finished();
    return ticks;
  }
View Full Code Here

        getGlobalPrefix(), getRedisConnector());
    List<FudgeMsg> messages = toFudgeMsg(redisReader.getLastKnownValues());
   
    final File outputFile = getOutputFile();
    ensureParentDirectory(outputFile);
    OperationTimer timer = new OperationTimer(s_logger, "Writing LKV for {} securities to disk", messages.size());
    FileOutputStream fos = null;
    try {
      fos = new FileOutputStream(outputFile);
      BufferedOutputStream bos = new BufferedOutputStream(fos, 4096);
      FudgeMsgWriter fmsw = s_fudgeContext.createMessageWriter(bos);
      for (FudgeMsg tick : messages) {
        fmsw.writeMessage(tick);
      }
      fmsw.flush();
    } catch (FileNotFoundException ex) {
      throw new OpenGammaRuntimeException("Could not open RedisLKVSnaphot file '" + outputFile.getAbsolutePath() + "'", ex);
    } finally {
      IOUtils.closeQuietly(fos);
    }
    timer.finished();
  }
View Full Code Here

TOP

Related Classes of com.opengamma.util.monitor.OperationTimer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.