List of usage examples for org.apache.commons.lang.time StopWatch start
public void start()
Start the stopwatch.
This method starts a new timing session, clearing any previous values.
From source file:com.streamsets.pipeline.stage.destination.jobtype.avroparquet.LargeInputFileIT.java
@Test public void testLargeFile() throws Exception { File inputFile = new File(getInputDir(), "input.avro"); File outputFile = new File(getOutputDir(), "input.parquet"); long recordCount = Long.valueOf(System.getProperty(TARGET_RECORD_COUNT, TARGET_RECORD_COUNT_DEFAULT)); StopWatch stopWatch = new StopWatch(); stopWatch.start(); generateAvroFile(AVRO_SCHEMA, inputFile, recordCount); stopWatch.stop();/*w ww. jav a 2 s . c o m*/ LOG.info("Created input avro file in {}, contains {} records and have {}.", stopWatch.toString(), recordCount, humanReadableSize(inputFile.length())); AvroConversionCommonConfig commonConfig = new AvroConversionCommonConfig(); AvroParquetConfig conf = new AvroParquetConfig(); commonConfig.inputFile = inputFile.getAbsolutePath(); commonConfig.outputDirectory = getOutputDir(); MapReduceExecutor executor = generateExecutor(commonConfig, conf, Collections.emptyMap()); ExecutorRunner runner = new ExecutorRunner.Builder(MapReduceDExecutor.class, executor) .setOnRecordError(OnRecordError.TO_ERROR).build(); runner.runInit(); Record record = RecordCreator.create(); record.set(Field.create(Collections.<String, Field>emptyMap())); stopWatch.reset(); stopWatch.start(); runner.runWrite(ImmutableList.of(record)); stopWatch.stop(); LOG.info("Generated output parquet file in {} and have {}.", stopWatch.toString(), humanReadableSize(outputFile.length())); Assert.assertEquals(0, runner.getErrorRecords().size()); runner.runDestroy(); validateParquetFile(new Path(outputFile.getAbsolutePath()), recordCount); }
From source file:eagle.storage.jdbc.entity.impl.JdbcEntityReaderImpl.java
@SuppressWarnings("unchecked") public <E extends Object> List<E> query(CompiledQuery query) throws Exception { QueryCriteriaBuilder criteriaBuilder = new QueryCriteriaBuilder(query, this.jdbcEntityDefinition.getJdbcTableName()); Criteria criteria = criteriaBuilder.build(); String displaySql = SqlBuilder.buildQuery(criteria).getDisplayString(); if (LOG.isDebugEnabled()) LOG.debug("Querying: " + displaySql); RecordMapper<E> recordMapper;// w w w .j av a 2 s .c o m if (query.isHasAgg()) { recordMapper = (RecordMapper<E>) new AggreagteRecordMapper(query, jdbcEntityDefinition); } else { recordMapper = new EntityRecordMapper(jdbcEntityDefinition); } final StopWatch stopWatch = new StopWatch(); List<E> result; try { stopWatch.start(); TorqueStatementPeerImpl peer = ConnectionManagerFactory.getInstance().getStatementExecutor(); result = peer.delegate().doSelect(criteria, recordMapper); LOG.info(String.format("Read %s records in %s ms (sql: %s)", result.size(), stopWatch.getTime(), displaySql)); } catch (Exception ex) { LOG.error("Failed to query by: " + displaySql + ", due to: " + ex.getMessage(), ex); throw new IOException("Failed to query by: " + displaySql, ex); } finally { stopWatch.stop(); } return result; }
From source file:com.netflix.paas.ArchaeusPassConfigurationTest.java
void timeConfig(MyConfig config, String name, int count) { StopWatch sw = new StopWatch(); sw.start(); for (int i = 0; i < count; i++) { for (Method method : MyConfig.class.getMethods()) { try { Object value = method.invoke(config); // System.out.println(name + " " + method.getName() + " " + value); } catch (Exception e) { e.printStackTrace();/*from www . j a v a 2 s .c o m*/ } } } System.out.println(name + " took " + sw.getTime()); }
From source file:ch.systemsx.cisd.openbis.generic.server.authorization.DefaultAccessController.java
public final Status isAuthorized(final IAuthSession session, final Method method, final Argument<?>[] arguments) throws UserFailureException { assert session != null : "Unspecified session"; assert method != null : "Unspecified method"; assert arguments != null : "Unspecified method arguments"; final StopWatch stopWatch = new StopWatch(); stopWatch.start(); try {// w w w . j a v a 2s. com final Set<Role> methodRoles = getMethodRoles(method); if (methodRoles.size() == 0) { // TODO 2008-08-07, Tomasz Pylak: why this is not a programming error? What a user // can do if a programmer does not put an authorization annotation for a method? final String msg = String.format(METHOD_ROLES_NOT_FOUND_TEMPLATE, MethodUtils.describeMethod(method)); return Status.createError(msg); } PersonPE person = session.tryGetPerson(); if (person == null || person.getAllPersonRoles().size() == 0) { final String msg = String.format(USER_ROLE_ASSIGNMENTS_NOT_FOUND_TEMPLATE, session.getUserName()); return Status.createError(msg); } final List<RoleWithIdentifier> userRoles = getUserRoles(person); userRoles.retainAll(methodRoles); if (userRoles.size() == 0) { final String msg = String.format(MATCHING_ROLE_NOT_FOUND_TEMPLATE, methodRoles, session.getUserName()); return Status.createError(msg); } if (arguments.length > 0) { for (final Argument<?> argument : arguments) { final Status status = PredicateExecutor.evaluate(person, userRoles, argument); if (status.getFlag().equals(StatusFlag.OK) == false) { return status; } } } return Status.OK; } finally { logTimeTaken(stopWatch, method); } }
From source file:com.liferay.portal.search.internal.SearchEngineInitializer.java
protected void reindex(Indexer<?> indexer) throws Exception { StopWatch stopWatch = new StopWatch(); stopWatch.start(); if (_log.isInfoEnabled()) { _log.info("Reindexing with " + indexer.getClass() + " started"); }//from w w w . j ava 2 s . co m indexer.reindex(new String[] { String.valueOf(_companyId) }); _usedSearchEngineIds.add(indexer.getSearchEngineId()); if (_log.isInfoEnabled()) { _log.info(StringBundler.concat("Reindexing with ", String.valueOf(indexer.getClass()), " completed in ", String.valueOf(stopWatch.getTime() / Time.SECOND), " seconds")); } }
From source file:com.nabla.project.fronter.selenium.tests.SimpleWebDriverSTest.java
public void testWithWrongInputS() throws Exception { // Get the StopWatch Object and start the StopWatch final StopWatch pageLoad = new StopWatch(); pageLoad.start(); // Create an instance of Loan Page class // and provide the driver final RollsPage loanPage = new RollsPage(/* SeleniumHelper.getDriver() */); // Open the Loan Calculator Page loanPage.get();/* w ww . ja v a 2s .c o m*/ loanPage.He_enters_rolls("ABC"); // wait for the application to get fully loaded /* * final WebElement findOwnerLink = (new WebDriverWait(SeleniumHelper.getDriver(), 5)).until(new ExpectedCondition<WebElement>() * { * @Override * public WebElement apply(final WebDriver d) * { * // d.get(baseUrl); * return d.findElement(By.name("loan_form:paybackTime")); * } * }); * findOwnerLink.click(); */ final WebDriverWait wait = new WebDriverWait(SeleniumHelper.getDriver(), 10); wait.until(ExpectedConditions.elementToBeClickable(By.name("rolls_form:score"))); SeleniumHelper.getDriver().manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); SeleniumHelper.getDriver().findElement(By.name("rolls_form:score")).click(); loanPage.Ensure_a_transaction_failure_message(2, "Please enter the amount of your loan. Ex. 200000: Validation Error: Specified attribute is not between the expected values of 1 and 1,000,000,000."); loanPage.Ensure_a_transaction_failure_message(3, "Please enter the number of years you have to pay back your loan. Ex. 30: Validation Error: Specified attribute is not between the expected values of 1 and 120."); SeleniumHelper.testTakesScreenshot("testWithWrongInputS.png", SeleniumHelper.getDriver()); // Thread.sleep(1000); SeleniumHelper.getSelenium().open("/fronter/"); SeleniumHelper.getSelenium().waitForPageToLoad("1500"); }
From source file:com.liferay.portal.convert.ConvertProcess.java
public void convert() throws ConvertException { try {/*ww w.j a va 2s. com*/ if (getPath() != null) { return; } StopWatch stopWatch = null; if (_log.isInfoEnabled()) { stopWatch = new StopWatch(); stopWatch.start(); _log.info("Starting conversion for " + getClass().getName()); } doConvert(); if (_log.isInfoEnabled()) { _log.info("Finished conversion for " + getClass().getName() + " in " + stopWatch.getTime() + " ms"); } } catch (Exception e) { throw new ConvertException(e); } finally { setParameterValues(null); MaintenanceUtil.cancel(); } }
From source file:au.id.hazelwood.xmltvguidebuilder.grabber.Grabber.java
public Grabber() { StopWatch stopWatch = new StopWatch(); stopWatch.start(); this.restTemplate = new RestTemplate(); stopWatch.stop();// ww w . j ava 2 s . c om LOGGER.debug("Grabber created in {}", formatDurationWords(stopWatch.getTime())); }
From source file:com.liferay.portal.scripting.internal.ScriptingImpl.java
@Override public Map<String, Object> eval(Set<String> allowedClasses, Map<String, Object> inputObjects, Set<String> outputNames, String language, String script) throws ScriptingException { ScriptingExecutor scriptingExecutor = _scriptingExecutors.get(language); if (scriptingExecutor == null) { throw new UnsupportedLanguageException(language); }//from w w w . j a va2 s. c om StopWatch stopWatch = new StopWatch(); stopWatch.start(); try { return scriptingExecutor.eval(allowedClasses, inputObjects, outputNames, script); } catch (Exception e) { throw new ScriptingException(getErrorMessage(script, e), e); } finally { if (_log.isDebugEnabled()) { _log.debug("Evaluated script in " + stopWatch.getTime() + " ms"); } } }
From source file:adams.gui.tools.wekainvestigator.tab.classifytab.evaluation.AbstractClassifierEvaluation.java
/** * Evaluates the classifier and updates the result item. * * @param classifier the current classifier * @param item the item to update/*from w w w.j av a 2 s .c o m*/ * @throws Exception if evaluation fails */ public void evaluate(Classifier classifier, ResultItem item) throws Exception { StopWatch watch; watch = new StopWatch(); watch.start(); doEvaluate(classifier, item); watch.stop(); if (item.hasRunInformation()) item.getRunInformation().add("Total time", (watch.getTime() / 1000.0) + "s"); }