Package com.opengamma.util.monitor

Examples of com.opengamma.util.monitor.OperationTimer


    // As the market data provider calls back to ALL listeners (i.e. potentially multiple
    // views), we need to make the subscription request outside the scope of the subscriptions
    // lock otherwise we can hit deadlocks when two similar views (e.g. same view, different
    // valuation times) are launched.
    if (!newSubscriptions.isEmpty()) {
      OperationTimer timer = new OperationTimer(s_logger, "Adding {} market data subscriptions", newSubscriptions.size());
      makeSubscriptionRequest(newSubscriptions);
      timer.finished();
    }
  }
View Full Code Here


    }

  }

  protected void initializeImpl(final long initId, final Collection<FunctionDefinition> functions) {
    final OperationTimer timer = new OperationTimer(s_logger, "Initializing {} function definitions", functions.size());
    final StaticFunctionRepository initialized = new StaticFunctionRepository(_initializedFunctionRepository);
    final PoolExecutor.Service<FunctionDefinition> jobs = getExecutorService().createService(new CompletionListener<FunctionDefinition>() {

      @Override
      public void success(final FunctionDefinition function) {
        if (function != null) {
          synchronized (initialized) {
            initialized.add(function);
          }
        }
      }

      @Override
      public void failure(final Throwable error) {
        s_logger.warn("Couldn't initialize function", error);
        // Don't take any further action - the error has been logged and the function is not in the "initialized" set
      }

    });
    getFunctionCompilationContext().setFunctionReinitializer(_reinitializer);
    synchronized (initialized) {
      for (final FunctionDefinition definition : functions) {
        initialized.remove(definition);
      }
    }
    for (final FunctionDefinition definition : functions) {
      jobs.execute(new Callable<FunctionDefinition>() {
        @Override
        public FunctionDefinition call() {
          try {
            definition.init(getFunctionCompilationContext());
            return definition;
          } catch (final UnsupportedOperationException e) {
            s_logger.warn("Function {}, is not supported in this configuration - {}", definition.getUniqueId(), e.getMessage());
            s_logger.info("Caught exception", e);
            return null;
          } catch (final Exception e) {
            s_logger.error("Couldn't initialize function {}", definition.getUniqueId());
            throw new OpenGammaRuntimeException("Couldn't initialize " + definition.getShortName(), e);
          }
        }
      });
    }
    try {
      jobs.join();
    } catch (final InterruptedException e) {
      Thread.interrupted();
      s_logger.warn("Interrupted while initializing function definitions.");
      throw new OpenGammaRuntimeException("Interrupted while initializing function definitions. ViewProcessor not safe to use.");
    }
    _initializedFunctionRepository = initialized;
    getFunctionCompilationContext().setFunctionReinitializer(null);
    getFunctionCompilationContext().setFunctionInitId(initId);
    timer.finished();
  }
View Full Code Here

    }
  }

  @Override
  public void start() {
    final OperationTimer timer = new OperationTimer(s_logger, "Starting on lifecycle call");
    _lifecycleLock.lock();
    try {
      if (_isStarted) {
        return;
      }
      s_logger.info("Starting on lifecycle call.");
      _isStarted = true;
    } finally {
      _lifecycleLock.unlock();
    }
    timer.finished();
    _viewProcessorEventListenerRegistry.notifyViewProcessorStarted();
  }
View Full Code Here

    }, "Putter");
   
    class GetRunner implements Runnable {
      @Override
      public void run() {
        OperationTimer timer = new OperationTimer(s_logger, "Getting {} entries", numGets);
        for (int i = 0; i < numGets; i++) {
          int maxIdentifier = (int) currentMaxIdentifier.get();
          long actualIdentifier = random.nextInt(maxIdentifier);
          dataStore.get(actualIdentifier);
        }
        long numMillis = timer.finished();

        double msPerGet = ((double) numMillis) / ((double) numGets);
        double getsPerSecond = 1000.0 / msPerGet;
       
        s_logger.info("for {} gets, {} ms/get, {} gets/sec", new Object[] {numGets, msPerGet, getsPerSecond});
View Full Code Here

    Environment dbEnvironment = createDbEnvironment(dbDir);
    FudgeContext fudgeContext = OpenGammaFudgeContext.getInstance();
    BerkeleyDBIdentifierMap idSource = new BerkeleyDBIdentifierMap(dbEnvironment, fudgeContext);
    idSource.start();

    OperationTimer timer = new OperationTimer(s_logger, "Put performance test with {} elements", numSpecifications);

    if (bulkOperation) {
      bulkOperationGetIdentifier(numRequirementNames, numIdentifiers, idSource);
    } else {
      singleOperationGetIdentifier(numRequirementNames, numIdentifiers, idSource);
    }

    idSource.stop();
    long numMillis = timer.finished();

    double msPerPut = ((double) numMillis) / ((double) numSpecifications);
    double putsPerSecond = 1000.0 / msPerPut;

    s_logger.info("Split time was {}ms/put, {}puts/sec", msPerPut, putsPerSecond);
View Full Code Here

      bulkOperationGetIdentifier(numRequirementNames, numIdentifiers, idSource);
    } else {
      singleOperationGetIdentifier(numRequirementNames, numIdentifiers, idSource);
    }

    OperationTimer timer = new OperationTimer(s_logger, "Get performance test with {} elements", numSpecifications);

    if (bulkOperation) {
      bulkOperationGetIdentifier(numRequirementNames, numIdentifiers, idSource);
    } else {
      singleOperationGetIdentifier(numRequirementNames, numIdentifiers, idSource);
    }

    long numMillis = timer.finished();
    idSource.stop();

    double msPerPut = ((double) numMillis) / ((double) numSpecifications);
    double putsPerSecond = 1000.0 / msPerPut;
View Full Code Here

    Environment dbEnvironment = BerkeleyDBViewComputationCacheSource.constructDatabaseEnvironment(dbDir, false);
   
    BerkeleyDBBinaryDataStore dataStore = new BerkeleyDBBinaryDataStore(dbEnvironment, "putPerformanceTest");
    dataStore.start();
   
    OperationTimer timer = new OperationTimer(s_logger, "Writing {} entries", numEntries);
   
    int randRange = maxEntrySize - minEntrySize;
    for (int i = 0; i < numEntries; i++) {
      int nBytes = minEntrySize + random.nextInt(randRange);
      byte[] bytes = new byte[nBytes];
      random.nextBytes(bytes);
      dataStore.put(i, bytes);
    }
   
    long numMillis = timer.finished();

    double msPerPut = ((double) numMillis) / ((double) numEntries);
    double putsPerSecond = 1000.0 / msPerPut;
   
    s_logger.info("for {} entries, {} ms/put, {} puts/sec", new Object[] {numEntries, msPerPut, putsPerSecond});
View Full Code Here

      byte[] bytes = new byte[nBytes];
      random.nextBytes(bytes);
      dataStore.put(i, bytes);
    }
   
    OperationTimer timer = new OperationTimer(s_logger, "Loading {} entries", numGets);
    for (int j = 0; j < numCycles; j++) {
      for (int i = 0; i < numEntries; i++) {
        byte[] data = dataStore.get(i);
        assertNotNull(data);
        assertTrue(data.length >= minEntrySize);
        assertTrue(data.length <= maxEntrySize);
      }
    }
   
    long numMillis = timer.finished();

    double msPerGet = ((double) numMillis) / ((double) numGets);
    double getsPerSecond = 1000.0 / msPerGet;
   
    s_logger.info("for {} gets, {} ms/get, {} gets/sec", new Object[] {numGets, msPerGet, getsPerSecond});
View Full Code Here

    final byte[] bytes = new byte[100];
    random.nextBytes(bytes);
    Thread tPut = new Thread(new Runnable() {
      @Override
      public void run() {
        OperationTimer timer = new OperationTimer(s_logger, "Putting {} entries", numEntries);
        for (int i = 0; i < numEntries; i++) {
          random.nextBytes(bytes);
          dataStore.put(i, bytes);
          currentMaxIdentifier.set(i);
        }
        long numMillis = timer.finished();

        double msPerPut = ((double) numMillis) / ((double) numGets);
        double putsPerSecond = 1000.0 / msPerPut;
       
        s_logger.info("for {} puts, {} ms/put, {} puts/sec", new Object[] {numEntries, msPerPut, putsPerSecond});
      }
     
    }, "Putter");
   
    class GetRunner implements Runnable {
      @Override
      public void run() {
        OperationTimer timer = new OperationTimer(s_logger, "Getting {} entries", numGets);
        for (int i = 0; i < numGets; i++) {
          int maxIdentifier = (int) currentMaxIdentifier.get();
          long actualIdentifier = random.nextInt(maxIdentifier);
          dataStore.get(actualIdentifier);
        }
        long numMillis = timer.finished();

        double msPerGet = ((double) numMillis) / ((double) numGets);
        double getsPerSecond = 1000.0 / msPerGet;
       
        s_logger.info("for {} gets, {} ms/get, {} gets/sec", new Object[] {numGets, msPerGet, getsPerSecond});
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.