List of usage examples for com.google.common.base Stopwatch createStarted
@CheckReturnValue public static Stopwatch createStarted()
From source file:org.apache.drill.test.framework.DrillTestOdbc.java
public void run() { final Stopwatch stopwatch = Stopwatch.createStarted(); this.thread = Thread.currentThread(); setTestStatus(TestStatus.RUNNING);//from ww w . j a va 2s. co m try { outputFilename = Utils.generateOutputFileName(modeler.queryFilename, modeler.testId, false) + "_" + id; } catch (IOException e) { LOG.error(e.getMessage()); throw new RuntimeException(e); } CmdConsOut cmdConsOut = null; String command = System.getProperty("user.dir") + "/" + Utils.getDrillTestProperties().get("DRILL_TEST_DATA_DIR") + "/" + modeler.script + " " + modeler.queryFilename + " " + outputFilename; LOG.info("Running test " + command); try { cmdConsOut = Utils.execCmd(command); LOG.info(cmdConsOut.consoleOut); switch (cmdConsOut.exitCode) { case 0: TestVerifier testVerifier = new TestVerifier(); try { setTestStatus(testVerifier.verifyResultSet(modeler.expectedFilename, outputFilename)); } catch (VerificationException e) { fail(TestStatus.VERIFICATION_FAILURE, e); } ; break; case 1: setTestStatus(TestStatus.EXECUTION_FAILURE); break; case 2: setTestStatus(TestStatus.VERIFICATION_FAILURE); break; case 3: setTestStatus(TestStatus.ORDER_MISMATCH); break; case 4: setTestStatus(TestStatus.TIMEOUT); break; case 5: setTestStatus(TestStatus.CANCELED); default: setTestStatus(TestStatus.EXECUTION_FAILURE); } } catch (Exception e) { fail(TestStatus.EXECUTION_FAILURE, e); } finally { if (testStatus == TestStatus.PASS && !TestDriver.OPTIONS.outputQueryResult) { Utils.deleteFile(outputFilename); } duration = stopwatch; LOG.info(testStatus + " (" + stopwatch + ") " + modeler.script + " " + modeler.queryFilename); } }
From source file:org.hawkular.metrics.core.jobs.CompressData.java
@Override public Completable call(JobDetails jobDetails) { // Rewind to previous timeslice Stopwatch stopwatch = Stopwatch.createStarted(); logger.info("Starting execution"); long previousBlock = DateTimeService.getTimeSlice( new DateTime(jobDetails.getTrigger().getTriggerTime(), DateTimeZone.UTC).minus(DEFAULT_BLOCK_SIZE), DEFAULT_BLOCK_SIZE).getMillis(); Observable<? extends MetricId<?>> metricIds = metricsService.findAllMetrics().map(Metric::getMetricId) .filter(m -> (m.getType() == GAUGE || m.getType() == COUNTER || m.getType() == AVAILABILITY)); // Fetch all partition keys and compress the previous timeSlice return Completable.fromObservable(metricsService.compressBlock(metricIds, previousBlock) .doOnError(t -> logger.warn("Failed to compress data", t)).doOnCompleted(() -> { stopwatch.stop();/* w w w .j av a 2 s . co m*/ logger.info("Finished compressing data in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms"); })); // TODO Optimization - new worker per token - use parallelism in Cassandra // Configure the amount of parallelism? }
From source file:org.terasology.polyworld.TriangleLookup.java
/** * Creates a lookup image for the graph's region triangles *///www . j ava 2 s. com public TriangleLookup(Graph graph) { bounds = graph.getBounds(); // TODO: maybe use USHORT_GRAY instead image = new BufferedImage(bounds.width(), bounds.height(), BufferedImage.TYPE_INT_RGB); Graphics2D g = image.createGraphics(); g.translate(-bounds.minX(), -bounds.minY()); try { Stopwatch sw = Stopwatch.createStarted(); triangles = drawTriangles(g, graph); logger.debug("Cached {} triangle lookups in {}ms.", triangles.size(), sw.elapsed(TimeUnit.MILLISECONDS)); } finally { g.dispose(); } dataBuffer = (DataBufferInt) image.getRaster().getDataBuffer(); }
From source file:com.twitter.distributedlog.io.LZ4CompressionCodec.java
@Override public byte[] compress(byte[] data, int offset, int length, OpStatsLogger compressionStat) { Preconditions.checkNotNull(data);/*from w w w . ja v a 2 s . c o m*/ Preconditions.checkArgument(offset >= 0 && offset < data.length); Preconditions.checkArgument(length >= 0); Preconditions.checkNotNull(compressionStat); Stopwatch watch = Stopwatch.createStarted(); byte[] compressed = compressor.compress(data, offset, length); compressionStat.registerSuccessfulEvent(watch.elapsed(TimeUnit.MICROSECONDS)); return compressed; }
From source file:JDBCExecutor.java
public JDBCExecutor(String connectURL, String userName, String password) throws SQLException { this.connectURL = connectURL; this.userName = userName; this.password = password; stopwatch = Stopwatch.createStarted(); }
From source file:org.balloon_project.overflight.service.RelationService.java
@Transactional public void save(List<Triple> triples) { Stopwatch watchComplete = Stopwatch.createStarted(); logger.info(triples.size() + " triples to persist"); for (Triple triple : triples) { save(triple);//from w w w . ja v a 2 s . co m } long miliseconds = watchComplete.stop().elapsed(TimeUnit.MILLISECONDS); if (triples.size() != 0) { logger.info(triples.size() + " relations persisted. (Duration: " + miliseconds + "ms => " + (miliseconds / triples.size()) + " ms/triple)"); } }
From source file:org.apache.drill.test.framework.DrillTestScript.java
public void run() { final Stopwatch stopwatch = Stopwatch.createStarted(); this.thread = Thread.currentThread(); setTestStatus(TestStatus.RUNNING);// www . j a va 2 s . c om try { outputFilename = Utils.generateOutputFileName(modeler.queryFilename, modeler.testId, false) + "_" + id; } catch (IOException e) { LOG.error(e.getMessage()); throw new RuntimeException(e); } CmdConsOut cmdConsOut = null; String command = System.getProperty("user.dir") + "/" + Utils.getDrillTestProperties().get("DRILL_TEST_DATA_DIR") + "/" + modeler.script + " " + modeler.queryFilename + " " + outputFilename; LOG.info("Running test " + command); try { cmdConsOut = Utils.execCmd(command); LOG.info(cmdConsOut.consoleOut); switch (cmdConsOut.exitCode) { case 0: setTestStatus(TestStatus.PASS); break; case 1: setTestStatus(TestStatus.EXECUTION_FAILURE); break; case 2: setTestStatus(TestStatus.VERIFICATION_FAILURE); break; case 3: setTestStatus(TestStatus.ORDER_MISMATCH); break; case 4: setTestStatus(TestStatus.TIMEOUT); break; case 5: setTestStatus(TestStatus.CANCELED); default: setTestStatus(TestStatus.EXECUTION_FAILURE); } } catch (Exception e) { fail(TestStatus.EXECUTION_FAILURE, e); } finally { duration = stopwatch; LOG.info(testStatus + " (" + stopwatch + ") " + modeler.script + " " + modeler.queryFilename); } }
From source file:org.apache.geode.test.dunit.rules.DistributedDisconnectRule.java
public static void disconnect() { Stopwatch stopwatch = Stopwatch.createStarted(); InternalDistributedSystem system = InternalDistributedSystem.getConnectedInstance(); while (system != null && stopwatch.elapsed(MINUTES) < 10) { system = InternalDistributedSystem.getConnectedInstance(); try {/*from w w w .jav a2 s. c om*/ system.disconnect(); } catch (Exception ignore) { // ignored } } AdminDistributedSystemImpl adminSystem = AdminDistributedSystemImpl.getConnectedInstance(); if (adminSystem != null) { adminSystem.disconnect(); } }
From source file:com.teradata.tempto.internal.hadoop.hdfs.DefaultHdfsDataSourceWriter.java
private boolean isDataUpToDate(String dataSourcePath, DataSource dataSource) { Stopwatch stopwatch = Stopwatch.createStarted(); Optional<String> storedRevisionMarker = revisionStorage.get(dataSourcePath); LOGGER.debug("revisionMarker.get(\"{}\") took {}ms", dataSourcePath, stopwatch.elapsed(TimeUnit.MILLISECONDS)); if (storedRevisionMarker.isPresent()) { if (storedRevisionMarker.get().equals(dataSource.revisionMarker())) { LOGGER.debug("Directory {} ({}) already exists, skipping generation of data", dataSourcePath, storedRevisionMarker.get()); return true; } else {//from w w w .j ava2s. co m LOGGER.info( "Directory {} ({}) already exists, but has different revision marker than expected: {}, so data will be regenerated", dataSourcePath, storedRevisionMarker.get(), dataSource.revisionMarker()); } } return false; }
From source file:org.graylog2.indexer.retention.strategies.ClosingRetentionStrategy.java
@Override public void retain(String indexName) { final Stopwatch sw = Stopwatch.createStarted(); indices.close(indexName);// w w w . j a v a 2s . co m LOG.info("Finished index retention strategy [close] for index <{}> in {}ms.", indexName, sw.stop().elapsed(TimeUnit.MILLISECONDS)); }