Package com.opengamma.util.monitor

Examples of com.opengamma.util.monitor.OperationTimer


    return (FutureBundleBean) query.uniqueResult();
  }
 
  @Override
  public void persistFutureBundleBeans(final Date now, final FutureSecurityBean future) {
    OperationTimer timer = new OperationTimer(s_logger, "persistFutureBundleBeans");
    final Set<FutureBundleBean> beanBasket = future.getBasket();
    final List<FutureBundleBean> dbBasket = getFutureBundleBeans(now, future);
    if (now != null) {
      // anything in the database (at this timestamp), but not in the basket must be "terminated" at this timestamp
      boolean beansUpdated = false;
      for (FutureBundleBean dbBundle : dbBasket) {
        if (!beanBasket.contains(dbBundle)) {
          dbBundle.setEndDate(now);
          getSession().update(dbBundle);
          beansUpdated = true;
        }
      }
      if (beansUpdated) {
        getSession().flush();
        beansUpdated = false;
      }
      // anything not in the database (at this timestamp), but in the basket must be added:
      for (FutureBundleBean beanBundle : beanBasket) {
        if (!dbBasket.contains(beanBundle)) {
          final FutureBundleBean next = nextFutureBundleBean(now, future);
          if (next != null) {
            beanBundle.setId(next.getId());
            beanBundle.setEndDate(next.getEndDate());
            next.setStartDate(now);
            getSession().update(next);
          } else {
            beanBundle.setStartDate(now);
            beanBundle.setEndDate(null);
            if (beanBundle.getId() != null) {
              getSession().update(beanBundle);
            } else {
              Long id = (Long) getSession().save(beanBundle);
              beanBundle.setId(id);
            }
          }
          beansUpdated = true;
        }
      }
      if (beansUpdated) {
        getSession().flush();
      }
    } else {
      // anything in the database with any timestamp that isn't null/null must be deleted
      // anything in the database, but not in the basket, must be deleted
      boolean beansUpdated = false;
      for (FutureBundleBean dbBundle : dbBasket) {
        if (!beanBasket.contains(dbBundle)) {
          getSession().delete(dbBundle);
          beansUpdated = true;
        } else if ((dbBundle.getStartDate() != null) || (dbBundle.getEndDate() != null)) {
          dbBundle.setStartDate(null);
          dbBundle.setEndDate(null);
          getSession().update(dbBundle);
          beansUpdated = true;
        }
      }
      // anything not in the database, but in the basket, must be added (null/null)
      for (FutureBundleBean beanBundle : beanBasket) {
        if (!dbBasket.contains(beanBundle)) {
          beanBundle.setStartDate(null);
          beanBundle.setEndDate(null);
          if (beanBundle.getId() != null) {
            getSession().update(beanBundle);
          } else {
            Long id = (Long) getSession().save(beanBundle);
            beanBundle.setId(id);
          }
          beansUpdated = true;
        }
      }
      if (beansUpdated) {
        getSession().flush();
      }
    }
    timer.finished();
  }
View Full Code Here


          res += function.evaluate(x);
        }
      }
      res *= 2;
      if (BENCHMARK_CYCLES > 0) {
        final OperationTimer timer = new OperationTimer(s_logger, "processing {} cycles on integral", BENCHMARK_CYCLES);
        for (int count = 0; count < BENCHMARK_CYCLES; count++) {
          for (int i = 0; i < 100; i++) {
            final double x = -15. + i * 30. / 200.0;
            res += function.evaluate(x);
          }
        }
        timer.finished();
      }
      res *= 2;
    }
  }
View Full Code Here

  public void testIntegral() {
    for (int i = 0; i < WARMUP_CYCLES; i++) {
      priceWithIntegral();
    }
    if (BENCHMARK_CYCLES > 0) {
      final OperationTimer timer = new OperationTimer(s_logger, "processing {} cycles on integral", BENCHMARK_CYCLES);
      for (int i = 0; i < BENCHMARK_CYCLES; i++) {
        priceWithIntegral();
      }
      timer.finished();
    }
  }
View Full Code Here

  public void testIntegralCorrection() {
    for (int i = 0; i < WARMUP_CYCLES; i++) {
      priceWithIntegralCorrection();
    }
    if (BENCHMARK_CYCLES > 0) {
      final OperationTimer timer = new OperationTimer(s_logger, "processing {} cycles on integral (corrected)", BENCHMARK_CYCLES);
      for (int i = 0; i < BENCHMARK_CYCLES; i++) {
        priceWithIntegralCorrection();
      }
      timer.finished();
    }
  }
View Full Code Here

  public void testFFT() {
    for (int i = 0; i < WARMUP_CYCLES; i++) {
      priceWithFFT();
    }
    if (BENCHMARK_CYCLES > 0) {
      final OperationTimer timer = new OperationTimer(s_logger, "processing {} cycles on FFT", BENCHMARK_CYCLES);
      for (int i = 0; i < BENCHMARK_CYCLES; i++) {
        priceWithFFT();
      }
      timer.finished();
    }
  }
View Full Code Here

   */
  private synchronized void updateServer(boolean catchExceptions) {
    Collection<LiveDataSpecification> specs = getSpecs(_persistentSubscriptions);
    Set<LiveDataSpecification> persistentSubscriptionsToMake = new HashSet<LiveDataSpecification>(specs);
   
    OperationTimer operationTimer = new OperationTimer(s_logger, "Updating server's persistent subscriptions {}", persistentSubscriptionsToMake.size());
   
    int partitionSize = 50; //Aim is to make sure we can convert subscriptions quickly enough that nothing expires, and to leave the server responsive, and make retrys not take too long

    List<List<LiveDataSpecification>> partitions = Lists.partition(Lists.newArrayList(persistentSubscriptionsToMake), partitionSize);
    for (List<LiveDataSpecification> partition : partitions) {
     
      Map<LiveDataSpecification, MarketDataDistributor> marketDataDistributors = _server.getMarketDataDistributors(persistentSubscriptionsToMake);
      for (Entry<LiveDataSpecification, MarketDataDistributor> distrEntry : marketDataDistributors.entrySet()) {
        if (distrEntry.getValue() != null) {
          //Upgrade or no/op should be fast, lets do it to avoid expiry
          createPersistentSubscription(catchExceptions, distrEntry.getKey());
          persistentSubscriptionsToMake.remove(distrEntry.getKey());
        }
      }
     
     
      SetView<LiveDataSpecification> toMake = Sets.intersection(new HashSet<LiveDataSpecification>(partition), persistentSubscriptionsToMake);
      if (!toMake.isEmpty()) {
        createPersistentSubscription(catchExceptions, toMake); //PLAT-1632
        persistentSubscriptionsToMake.removeAll(toMake);
      }
    }
    operationTimer.finished();
    s_logger.info("Server updated");
  }
View Full Code Here

    final int nStarts = getStartValues().length;
    for (int i = 0; i < hotspotWarmupCycles; i++) {
      testNoisyFit();
    }
    if (benchmarkCycles > 0) {
      final OperationTimer timer = new OperationTimer(getlogger(), "processing {} cycles fitting smile", nStarts * benchmarkCycles);
      for (int i = 0; i < benchmarkCycles; i++) {
        testNoisyFit();
      }
      final long time = timer.finished();
      getlogger().info("time per fit: " + ((double) time) / benchmarkCycles / nStarts + "ms");

    }
  }
View Full Code Here

    final int benchmarkCycles = 1000;
    for (int i = 0; i < hotspotWarmupCycles; i++) {
      testNoisyFit();
    }
    if (benchmarkCycles > 0) {
      final OperationTimer timer = new OperationTimer(_logger, "processing {} cycles fitting SABR smile", benchmarkCycles);
      for (int i = 0; i < benchmarkCycles; i++) {
        testNoisyFit();
      }
      timer.finished();
    }
  }
View Full Code Here

    }
    for (int i = 0; i < hotspotWarmupCycles; i++) {
      doOldTest(options, data, start, fixed, fitter);
    }
    if (benchmarkCycles > 0) {
      final OperationTimer timer = new OperationTimer(_logger, "processing {} cycles fitting SABR smile - old", benchmarkCycles);
      for (int i = 0; i < benchmarkCycles; i++) {
        doOldTest(options, data, start, fixed, fitter);
      }
      timer.finished();
    }

  }
View Full Code Here

    double x = 0;
    for (int i = 0; i < _hotspotWarmupCycles; i++) {
      x += f.evaluate(data);
    }
    if (_benchmarkCycles > 0) {
      final OperationTimer timer = new OperationTimer(_logger, "processing {} cycles generating SABR smile", _benchmarkCycles);
      for (int i = 0; i < _benchmarkCycles; i++) {
        x += f.evaluate(data);
      }
      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.