List of usage examples for java.lang System nanoTime
@HotSpotIntrinsicCandidate public static native long nanoTime();
From source file:com.cloudera.oryx.ml.serving.als.LoadIT.java
@Test public void testContainerOverhead() { long startNS = System.nanoTime(); int requests = 10000; for (int i = 0; i < requests; i++) { try {//from w w w .ja v a2 s . c o m target("/").request().get(LIST_ID_VALUE_TYPE); } catch (NotFoundException nfe) { // continue } } long usecPerRequest = Math.round((System.nanoTime() - startNS) / (requests * 1000.0)); log.info("{} microseconds / request", usecPerRequest); Assert.assertTrue(usecPerRequest < 3000); }
From source file:apiserver.services.pdf.service.AddFooterToPdfCFService.java
public Object execute(Message<?> message) throws ColdFusionException { AddFooterPdfResult props = (AddFooterPdfResult) message.getPayload(); try {/*w w w . j a va2 s . com*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<ByteArrayResult> future = exec .submit(new AddFooterCallable(props.getFile().getFileBytes(), props.getOptions())); ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getBytes()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:apiserver.services.pdf.service.AddHeaderToPdfCFService.java
public Object execute(Message<?> message) throws ColdFusionException { AddHeaderPdfResult props = (AddHeaderPdfResult) message.getPayload(); try {/*ww w. j a v a 2 s .c o m*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<ByteArrayResult> future = exec .submit(new AddFooterCallable(props.getFile().getFileBytes(), props.getOptions())); ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getBytes()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:apiserver.services.pdf.service.TransformPdfCFService.java
public Object execute(Message<?> message) throws ColdFusionException { TransformPdfResult props = (TransformPdfResult) message.getPayload(); try {/*from w ww .j av a 2 s. c o m*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<ByteArrayResult> future = exec .submit(new TransformPdfCallable(props.getFile().getFileBytes(), props.getOptions())); ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getBytes()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:com.civprod.util.concurrent.locks.CompositeLock.java
@Override public boolean tryLock(long time, TimeUnit unit) throws InterruptedException { long timeInNanos = unit.convert(time, TimeUnit.NANOSECONDS); long startTime = System.nanoTime(); int currentLockNumber = 0; boolean locked = true; try {/*from w w w. j av a 2 s . c o m*/ while (locked && (currentLockNumber < interLocks.size())) { long currentWaitTime = timeInNanos - (System.nanoTime() - startTime); if (interLocks.get(currentLockNumber).tryLock(currentWaitTime, TimeUnit.NANOSECONDS)) { currentLockNumber++; } else { locked = false; } } } catch (Exception ex) { locked = false; throw (ex); } finally { if (!locked) { while (currentLockNumber >= 1) { currentLockNumber--; interLocks.get(currentLockNumber).unlock(); } } } return locked; }
From source file:apiserver.services.pdf.service.AddPdfWatermarkCFService.java
public Object execute(Message<?> message) throws ColdFusionException { WatermarkPdfResult props = (WatermarkPdfResult) message.getPayload(); try {/*from www .j ava 2 s . c om*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<ByteArrayResult> future = exec .submit(new AddWatermarkCallable(props.getFile().getFileBytes(), props.getOptions())); ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getBytes()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:com.cloudera.oryx.app.serving.als.model.LoadTestALSModelFactory.java
public static ALSServingModel buildTestModel() { log.info("Building load test model..."); System.gc();/*from w ww. ja v a 2 s.co m*/ long startMemory = JVMUtils.getUsedMemory(); ALSServingModel model = new ALSServingModel(FEATURES, true, LSH_SAMPLE_RATE, new TestALSRescorerProvider()); AtomicLong totalEntries = new AtomicLong(); int numCores = Runtime.getRuntime().availableProcessors(); log.info("Adding {} users", USERS); AtomicInteger userCount = new AtomicInteger(); ExecUtils.doInParallel(numCores, i -> { RandomGenerator random = RandomManager.getRandom(((long) i << 32) ^ System.nanoTime()); PoissonDistribution itemPerUserDist = new PoissonDistribution(random, AVG_ITEMS_PER_USER, PoissonDistribution.DEFAULT_EPSILON, PoissonDistribution.DEFAULT_MAX_ITERATIONS); for (int user = userCount.getAndIncrement(); user < USERS; user = userCount.getAndIncrement()) { String userID = "U" + user; model.setUserVector(userID, VectorMath.randomVectorF(FEATURES, random)); int itemsPerUser = itemPerUserDist.sample(); totalEntries.addAndGet(itemsPerUser); Collection<String> knownIDs = new ArrayList<>(itemsPerUser); for (int item = 0; item < itemsPerUser; item++) { knownIDs.add("I" + random.nextInt(ITEMS)); } model.addKnownItems(userID, knownIDs); } }); log.info("Adding {} items", ITEMS); AtomicInteger itemCount = new AtomicInteger(); ExecUtils.doInParallel(numCores, i -> { RandomGenerator random = RandomManager.getRandom(((long) i << 32) ^ System.nanoTime()); for (int item = itemCount.getAndIncrement(); item < ITEMS; item = itemCount.getAndIncrement()) { model.setItemVector("I" + item, VectorMath.randomVectorF(FEATURES, random)); } }); System.gc(); long endMemory = JVMUtils.getUsedMemory(); log.info("Built model over {} users, {} items, {} features, {} entries, using {}MB", USERS, ITEMS, FEATURES, totalEntries, (endMemory - startMemory) / 1_000_000); log.info("Model: {}", model); return model; }
From source file:apiserver.services.pdf.service.ExtractPdfImagesCFService.java
public Object execute(Message<?> message) throws ColdFusionException { ExtractImageResult props = (ExtractImageResult) message.getPayload(); try {//from w w w. ja va2 s. c o m long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<CollectionResult> future = exec .submit(new ExtractImageCallable(props.getFile().getFileBytes(), props.getOptions())); CollectionResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getCollection()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:apiserver.services.pdf.service.GenerateThumbnailPdfCFService.java
public Object execute(Message<?> message) throws ColdFusionException { SecurePdfResult props = (SecurePdfResult) message.getPayload(); try {//from w ww . jav a 2 s. c o m long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<CollectionResult> future = exec .submit(new GenerateThumbnailCallable(props.getFile().getFileBytes(), props.getOptions())); CollectionResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); //props.setResult(_result.getBytes()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:dk.statsbiblioteket.netark.dvenabler.wrapper.SortedSetDocValuesWrapper.java
public SortedSetDocValuesWrapper(AtomicReader reader, DVConfig field) throws IOException { this.reader = reader; this.field = field; FIELDS = new HashSet<>(Arrays.asList(field.getName())); log.info("Creating map for SortedSetDocValues for field '" + field + "'"); long startTime = System.nanoTime(); values = fill();/*from www.ja v a 2 s. com*/ tracker = new ProgressTracker(field.getName(), log, reader.maxDoc()); log.info("Finished creating SortedSetDocValues with " + values.size() + " unique values for " + reader.maxDoc() + " docs for field '" + field + "' in " + ((System.nanoTime() - startTime) / 1000000 / 1000) + "ms"); }