List of usage examples for org.apache.commons.lang.time StopWatch stop
public void stop()
Stop the stopwatch.
This method ends a new timing session, allowing the time to be retrieved.
From source file:de.unisb.cs.st.javalanche.mutation.util.DBPerformanceTest.java
private void queryMutations() { List<Long> ids = new ArrayList<Long>(); for (Mutation m : getMutations()) { ids.add(m.getId());/*from w ww.j a va2s. c o m*/ } StringBuilder sb = new StringBuilder(); StopWatch stopWatch = new StopWatch(); stopWatch.start(); List<Mutation> mutations = QueryManager.getMutationsByIds(ids.toArray(new Long[0])); for (Mutation mutation : mutations) { sb.append(mutation.getClassName()); } stopWatch.stop(); System.out.printf("Querying %d mutations took %s -- checkvalue: %d\n", LIMIT, DurationFormatUtils.formatDurationHMS(stopWatch.getTime()), sb.length()); }
From source file:com.cedarsoft.serialization.test.performance.StaxMateDelegatePerformance.java
private void runBenchmark(@Nonnull Runnable runnable, final int count) { //Warmup/* w w w. j a v a 2 s . c om*/ runnable.run(); runnable.run(); runnable.run(); List<Long> times = new ArrayList<Long>(); for (int i = 0; i < count; i++) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); runnable.run(); stopWatch.stop(); times.add(stopWatch.getTime()); } System.out.println("-----------------------"); for (Long time : times) { System.out.println("--> " + time); } System.out.println("-----------------------"); }
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();/*from w w w. j a va 2 s . c o m*/ 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++; } } } } 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:gov.nasa.ensemble.core.jscience.xml.XMLProfilesResource.java
@Override @SuppressWarnings("unchecked") protected void doLoad(InputStream inputStream, Map<?, ?> options) { String extension = getURI().fileExtension(); if (!SUPPORTED_EXTENSIONS.contains(extension.toLowerCase())) { LOGGER.warn("\"" + extension + "\" is not a standard extension for a ProfileResource."); }// ww w .ja v a 2s .co m ProfilesParser parser = XMLProfileParser.getInstance(); inputStream = ProgressMonitorInputStream.wrapInputStream(this, inputStream, options); StopWatch sw = new StopWatch(); sw.start(); try { parser.parse(getURI(), inputStream); } finally { IOUtils.closeQuietly(inputStream); } sw.stop(); LOGGER.debug("Loaded profiles from " + getURI() + " in " + sw.toString()); List<Profile> profiles = parser.getProfiles(); if (profiles != null) { getContents().addAll(profiles); } setModified(false); }
From source file:au.id.hazelwood.xmltvguidebuilder.config.ConfigFactory.java
public ConfigFactory() throws Exception { StopWatch stopWatch = new StopWatch(); stopWatch.start();//from w ww.j a v a2 s .com SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); schema = schemaFactory.newSchema(new StreamSource(toInputStream("/config.xsd"))); stopWatch.stop(); LOGGER.debug("ConfigFactory created in {}", formatDurationWords(stopWatch.getTime())); }
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();//from w w w . jav a2 s . com ApplicationContextLoader.unload(); // 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.couchbase.graph.CBGraphPerfTest.java
@Test @RunIf(value = PerfEnabledChecker.class) public void testCreateBinaryTreeWithDepthOf10() { System.out.println("-- testCreateBinaryTreeWithDepthOf10"); //Create a root node String uuid = UUID.randomUUID().toString(); Vertex root = graph.addVertex(uuid); StopWatch sw = new StopWatch(); sw.start();/*from w w w . j a v a 2 s . co m*/ add2Vertices(root, 0, 10); //add2Vertices(root, 0, 14); sw.stop(); System.out.println("Binary tree with a depth of 10 added in " + sw.getTime() + " ms"); //Traverse the tree sw = new StopWatch(); sw.start(); for (int i = 0; i < 10; i++) { Vertex left = root.getVertices(Direction.OUT, "to left").iterator().next(); root = left; } sw.stop(); System.out.println("Traversed tree in " + sw.getTime() + " ms"); }
From source file:net.craigstars.game.services.GameControllerTest.java
public void testGenerateTurn() { String token = getNextToken(); User user = getUser();//from w ww .ja va 2s. c o m Game game = gameController.createGame(user, token, Size.Tiny, Density.Sparse, 2); Race race = getRace(); gameController.joinGame(race.getUser(), race, game.getId()); // join an ai player User aiUser = getUser(token + "-ai"); aiUser.setAi(true); dao.getUserDao().save(aiUser); Race aiRace = getRace(user, token + "-ai"); gameController.joinGame(aiUser, aiRace, game.getId()); game = gameController.getGame(game.getId()); log.debug("\n\n\n\nStarting generateTurn\n\n\n\n"); StopWatch watch = new StopWatch(); watch.start(); int numYears = 50; // generate a bunch of turns for (int i = 0; i < numYears; i++) { gameController.submitTurn(user, game.getId()); } watch.stop(); log.debug("\n\n\nTime: {}ms", watch.getTime()); game = gameController.getGame(game.getId()); assertEquals(2400 + numYears, game.getYear()); }
From source file:com.microsoft.exchange.integration.ImpersonationClientIntegrationTest.java
/** * Similar to {@link #testGetUserAvailability()}, but uses {@link FindItem}. * /*from w ww . j a v a 2 s. co m*/ * @throws JAXBException */ @Test public void testFindMoreDetailedItemCalendarType() throws JAXBException { initializeCredentials(); FindItem request = constructFindItemRequest(DateHelper.makeDate("2012-10-12"), DateHelper.makeDate("2012-10-13"), emailAddress); StopWatch stopWatch = new StopWatch(); stopWatch.start(); FindItemResponse response = ewsClient.findItem(request); String captured = capture(response); log.info("testFindMoreDetailedItemCalendarType response: " + captured); stopWatch.stop(); log.debug("FindItem request completed in " + stopWatch); Assert.assertNotNull(response); Assert.assertEquals(expectedEventCount, response.getResponseMessages() .getCreateItemResponseMessagesAndDeleteItemResponseMessagesAndGetItemResponseMessages().size()); }
From source file:com.couchbase.graph.CBGraphPerfTest.java
/** * To add 1000 vertices/*ww w. j a v a 2 s . co m*/ */ @Test @RunIf(value = PerfEnabledChecker.class) public void testAdd1000Vertices() { System.out.println("-- testAdd1000Vertices"); //Generate some random id-s String[] uuids = new String[1000]; for (int i = 0; i < 1000; i++) { String uuid = UUID.randomUUID().toString(); uuids[i] = uuid; } StopWatch sw = new StopWatch(); sw.start(); //For each UUID add a vertex for (String uuid : uuids) { graph.addVertex(uuid); } sw.stop(); System.out.println("1000 verices added in " + sw.getTime() + " ms"); System.out.println("- Proof that the last one was added"); Vertex v = graph.getVertex(uuids[uuids.length - 1]); assertNotNull(v); }