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.cedarsoft.serialization.SplittingPerformanceRunner.java
private static void run(@Nonnull String description, @Nonnull Callable<String> callable) throws Exception { //Warmup/*w w w.j av a 2 s .c o m*/ for (int i = 0; i < 1000; i++) { assertEquals("1.0.0", callable.call()); } //Do the work StopWatch stopWatch = new StopWatch(); stopWatch.start(); for (int i = 0; i < 100000; i++) { assertEquals("1.0.0", callable.call()); } stopWatch.stop(); System.out.println(description + " took " + stopWatch.getTime()); }
From source file:de.unisb.cs.st.javalanche.mutation.util.DBPerformanceTest.java
private static void testWrite() { StopWatch stopWatch = new StopWatch(); stopWatch.start(); try {/* w w w . j av a 2s. c o m*/ File file = new File("test.txt"); file.deleteOnExit(); FileWriter fw = new FileWriter(file); BufferedWriter w = new BufferedWriter(fw); for (int i = 0; i < 50 * 1024 * 1024; i++) { w.append('x'); } w.close(); } catch (IOException e) { e.printStackTrace(); } stopWatch.stop(); System.out.printf("Writing file took %s\n", DurationFormatUtils.formatDurationHMS(stopWatch.getTime())); }
From source file:com.icantrap.collections.dawg.DawgValidationTest.java
@BeforeClass public static void init() throws IOException { assumeThat(System.getProperty("RUN_VALIDATION"), is("on")); StopWatch stopWatch = new StopWatch(); stopWatch.start(); dawg = Dawg.load(DawgValidationTest.class.getResourceAsStream("/twl06.dat")); stopWatch.stop();/*from w w w.j a v a 2 s .co m*/ System.out.println("Time to load " + dawg.nodeCount() + " node dawg: " + stopWatch.getTime() + " ms."); }
From source file:fr.cnrs.sharp.reasoning.Interlinking.java
/** * Generates a Jena Model with an SHA-512 fingerprint of a file content. * @param inputRawFile the file to be fingerprinted * @return a Jena Model with an SHA-512, based on PROV and tavernaprov vocabularies. * @throws IOException/* w w w . j av a 2 s . co m*/ */ public static Model fingerprint(Path inputRawFile) throws IOException { StopWatch sw = new StopWatch(); sw.start(); Model data = ModelFactory.createDefaultModel(); Path p = inputRawFile; String label = p.getFileName().toString(); System.out.println(); FileInputStream fis = new FileInputStream(p.toFile()); String sha512 = DigestUtils.sha512Hex(fis); StringBuffer sb = new StringBuffer(); sb.append("@base <http://fr.symetric> .\n" + "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n" + "@prefix prov: <http://www.w3.org/ns/prov#> .\n" + "@prefix tavernaprov: <http://ns.taverna.org.uk/2012/tavernaprov/> .\n" + "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"); sb.append("<#" + UUID.randomUUID().toString() + ">\n" + "\t a prov:Entity ;\n"); sb.append("\t rdfs:label \"" + label + "\"^^xsd:String ;\n"); sb.append("\t tavernaprov:sha512 \"" + sha512 + "\"^^xsd:String ."); RDFDataMgr.read(data, new StringReader(sb.toString()), null, Lang.TTL); fis.close(); return data; }
From source file:biz.netcentric.cq.tools.actool.helper.PurgeHelper.java
public static String deleteAcesFromAuthorizables(final Session session, final Set<String> authorizabeIDs, final Set<AclBean> aclBeans) throws UnsupportedRepositoryOperationException, RepositoryException, AccessControlException, PathNotFoundException, AccessDeniedException, LockException, VersionException { StopWatch sw = new StopWatch(); sw.start(); StringBuilder message = new StringBuilder(); AccessControlManager aMgr = session.getAccessControlManager(); long aceCounter = 0; for (AclBean aclBean : aclBeans) { if (aclBean != null) { for (AccessControlEntry ace : aclBean.getAcl().getAccessControlEntries()) { String authorizableId = ace.getPrincipal().getName(); if (authorizabeIDs.contains(authorizableId)) { String parentNodePath = aclBean.getParentPath(); String acePath = aclBean.getJcrPath(); aclBean.getAcl().removeAccessControlEntry(ace); aMgr.setPolicy(aclBean.getParentPath(), aclBean.getAcl()); AcHelper.LOG.info("removed ACE {} from ACL of node: {}", acePath, parentNodePath); message.append("removed ACE of principal: " + authorizableId + " from ACL of node: " + parentNodePath + "\n"); aceCounter++;// w w w .j a v a 2s. com } } } } sw.stop(); long executionTime = sw.getTime(); message.append("\n\nDeleted: " + aceCounter + " ACEs in repository"); message.append("\nExecution time: " + executionTime + " ms"); return message.toString(); }
From source file:com.xiaofengmetis.benchmark.BenchmarkUtils.java
public static Pair<Long, Integer> execute(Benchmark benchmark, int times) { StopWatch stopWatch = new StopWatch(); try {/*from w ww . jav a 2s . c om*/ benchmark.setup(); stopWatch.start(); for (int t = 0; t < times; t++) { benchmark.execute(); } stopWatch.stop(); benchmark.cleanup(); } catch (Exception ex) { throw new RuntimeException(ex); } return Pair.of(stopWatch.getTime(), times); }
From source file:com.liferay.wiki.util.WikiCacheUtil.java
public static WikiPageDisplay getDisplay(long nodeId, String title, PortletURL viewPageURL, PortletURL editPageURL, String attachmentURLPrefix) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); String key = _encodeKey(nodeId, title, viewPageURL.toString()); WikiPageDisplay pageDisplay = (WikiPageDisplay) _portalCache.get(key); if (pageDisplay == null) { pageDisplay = _getPageDisplay(nodeId, title, viewPageURL, editPageURL, attachmentURLPrefix); if (pageDisplay != null) { PortalCacheHelperUtil.putWithoutReplicator(_portalCache, key, pageDisplay); }//from w w w . ja v a 2 s .com } if (_log.isDebugEnabled()) { _log.debug(StringBundler.concat("getDisplay for {", String.valueOf(nodeId), ", ", title, ", ", String.valueOf(viewPageURL), ", ", String.valueOf(editPageURL), "} takes ", String.valueOf(stopWatch.getTime()), " ms")); } return pageDisplay; }
From source file:com.qualogy.qafe.web.ContextLoader.java
private static void create(ServletContext servletContext) throws MalformedURLException, URISyntaxException { String configLocation = servletContext.getInitParameter(CONFIG_FILE_PARAM); String contextPath = getContextPath(servletContext); QafeConfigurationManager contextInitialiser = new QafeConfigurationManager(contextPath); ApplicationContext springContext = WebApplicationContextUtils .getRequiredWebApplicationContext(servletContext); contextInitialiser.setSpringContext(springContext); qafeContext.putInstance(QafeConfigurationManager.class.getName(), contextInitialiser); StopWatch watch = new StopWatch(); watch.start(); ApplicationContextLoader.unload();//from w ww. java2 s . c o m // The default way: works on JBoss/Tomcat/Jetty String configFileLocation = servletContext.getRealPath("/WEB-INF/"); if (configFileLocation != null) { configFileLocation += File.separator + configLocation; logger.log(Level.INFO, "URL to config file on disk :" + configFileLocation + ")"); ApplicationContextLoader.load(configFileLocation, true); } else { // This is how a weblogic explicitly wants the fetching of resources. URL url = servletContext.getResource("/WEB-INF/" + configLocation); logger.log(Level.INFO, "Fallback scenario" + url.toString()); if (url != null) { logger.log(Level.INFO, "URL to config file " + url.toString()); ApplicationContextLoader.load(url.toURI(), true); } else { throw new RuntimeException( "Strange Error: /WEB-INF/ cannot be found. Check the appserver or installation directory."); } } watch.stop(); logger.log(Level.INFO, "Root WebApplicationContext: initialization completed in " + watch.getTime() + " ms"); }
From source file:com.qualogy.qafe.core.application.ApplicationContextLoader.java
public synchronized static void load(URI applicationFilePath, boolean validating) { logger.info("start application loading according to config file: [" + applicationFilePath + "]"); StopWatch watch = new StopWatch(); watch.start(); ApplicationStack contexts = read(applicationFilePath, validating); load(contexts, applicationFilePath); watch.stop();/* w w w.j a v a2 s .co m*/ logger.info("done loading from [" + applicationFilePath + "] in " + watch.getTime() + "ms"); ApplicationCluster.getInstance().putAll(contexts); }
From source file:com.liferay.portlet.wiki.util.WikiCacheUtil.java
public static WikiPageDisplay getDisplay(long nodeId, String title, PortletURL viewPageURL, PortletURL editPageURL, String attachmentURLPrefix) { StopWatch stopWatch = null; if (_log.isDebugEnabled()) { stopWatch = new StopWatch(); stopWatch.start(); }//from ww w . j a v a 2s. c o m String key = _encodeKey(nodeId, title, viewPageURL.toString()); WikiPageDisplay pageDisplay = (WikiPageDisplay) _portalCache.get(key); if (pageDisplay == null) { pageDisplay = _getPageDisplay(nodeId, title, viewPageURL, editPageURL, attachmentURLPrefix); _portalCache.put(key, pageDisplay); } if (_log.isDebugEnabled()) { _log.debug("getDisplay for {" + nodeId + ", " + title + ", " + viewPageURL + ", " + editPageURL + "} takes " + stopWatch.getTime() + " ms"); } return pageDisplay; }