List of usage examples for org.springframework.util StopWatch StopWatch
public StopWatch()
From source file:test.buddhabrot.BuddhabrotApp.java
public static void main(String[] args) { log.info("GridNode Starting..."); StopWatch sw = new StopWatch(); sw.start();//from w w w .jav a 2s. c o m GridNode node = Grid.startLightGridNode(); log.info("GridNode ID : " + node.getId()); log.info("Registered in Cluster : " + node.getNodeRegistrationService().getRegistration().getClusterId()); sw.stop(); log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]"); // Create App Instance final BuddhabrotApp app = new BuddhabrotApp(node); app.requestFocus(); // Create Buddhabrot Job BuddhabrotJob buddhabrotJob = new BuddhabrotJob(WIDTH, HEIGHT); // Start Job Submission sw.start(); System.err.println(new Date()); GridJobFuture future = node.getJobSubmissionService().submitJob(buddhabrotJob, new ResultCallback() { public void onResult(Serializable result) { log.debug("CALLBACK"); if (result == null) return; if (result instanceof int[][]) { app.onResult((int[][]) result); } } }); app.setFuture(future); }
From source file:com.auditbucket.client.Importer.java
public static void main(String args[]) { try {/* w w w.j a v a 2s. com*/ ArgumentParser parser = ArgumentParsers.newArgumentParser("ABImport").defaultHelp(true) .description("Import file formats to AuditBucket"); parser.addArgument("-s", "--server").setDefault("http://localhost/ab-engine") .help("Host URL to send files to"); parser.addArgument("-b", "--batch").setDefault(100).help("Default batch size"); parser.addArgument("-x", "--xref").setDefault(false).help("Cross References Only"); parser.addArgument("files").nargs("*").help( "Path and filename of Audit records to import in the format \"[/filepath/filename.ext],[com.import.YourClass],{skipCount}\""); Namespace ns = null; try { ns = parser.parseArgs(args); } catch (ArgumentParserException e) { parser.handleError(e); System.exit(1); } List<String> files = ns.getList("files"); if (files.isEmpty()) { parser.handleError(new ArgumentParserException("No files to parse", parser)); System.exit(1); } String b = ns.getString("batch"); int batchSize = 100; if (b != null && !"".equals(b)) batchSize = Integer.parseInt(b); StopWatch watch = new StopWatch(); watch.start(); logger.info("*** Starting {}", DateFormat.getDateTimeInstance().format(new Date())); long totalRows = 0; for (String file : files) { int skipCount = 0; List<String> items = Arrays.asList(file.split("\\s*,\\s*")); if (items.size() == 0) parser.handleError(new ArgumentParserException("No file arguments to process", parser)); int item = 0; String fileName = null; String fileClass = null; for (String itemArg : items) { if (item == 0) { fileName = itemArg; } else if (item == 1) { fileClass = itemArg; } else if (item == 2) skipCount = Integer.parseInt(itemArg); item++; } logger.debug("*** Calculated process args {}, {}, {}, {}", fileName, fileClass, batchSize, skipCount); totalRows = totalRows + processFile(ns.get("server").toString(), fileName, (fileClass != null ? Class.forName(fileClass) : null), batchSize, skipCount); } endProcess(watch, totalRows); logger.info("Finished at {}", DateFormat.getDateTimeInstance().format(new Date())); } catch (Exception e) { logger.error("Import error", e); } }
From source file:com.home.ln_spring.ch4.mi.MethodReplacementExample.java
private static void displayInfo(ReplacementTarget target) { System.out.println(target.formatMessage("Hello World!")); StopWatch stopWatch = new StopWatch(); stopWatch.start("perfTest"); for (int x = 0; x < 1000000; x++) { String out = target.formatMessage("foo"); }/* ww w. j av a 2 s. co m*/ stopWatch.stop(); System.out.println("1000000 invocations took: " + stopWatch.getTotalTimeMillis() + " ms."); }
From source file:com.home.ln_spring.ch4.mi.lookupDemo.java
public static void displayInfo(DemoBean bean) { MyHelper helper1 = bean.getMyHelper(); MyHelper helper2 = bean.getMyHelper(); System.out.println("Helper Instances the Same?: " + (helper1 == helper2)); StopWatch stopWatch = new StopWatch(); stopWatch.start("lookupDemo"); for (int x = 0; x < 100000; x++) { MyHelper helper = bean.getMyHelper(); helper.doSomethingHelpful();/*from www .j a v a 2 s . c o m*/ } stopWatch.stop(); System.out.println("100000 gets took " + stopWatch.getTotalTimeMillis() + " ms"); }
From source file:profiling.ProfilingInterceptor.java
@Override public Object invoke(MethodInvocation mi) throws Throwable { StopWatch sw = new StopWatch(); sw.start(mi.getMethod().getName());//from w w w . ja v a 2 s . c o m String methodName = mi.getMethod().getName(); if ("sayNigga".equals(methodName)) { System.out.println("FUCK YOU NIGGA!"); return null; } Object returnValue = mi.proceed(); sw.stop(); dumpInfo(mi, sw.getTotalTimeMillis()); return returnValue; }
From source file:com.swarmcn.user.web.config.SwaggerConfiguration.java
@Bean public Docket swaggerSpringfoxDocket() { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start();// ww w .j a v a2 s.co m Docket swaggerSpringMvcPlugin = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) .genericModelSubstitutes(ResponseEntity.class).select().build(); watch.stop(); log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis()); return swaggerSpringMvcPlugin; }
From source file:com.chf.sample.spring.config.SwaggerConfig.java
@Bean public Docket swaggerSpringfoxDocket() { StopWatch watch = new StopWatch(); watch.start();//w w w . j av a 2s. co m Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) .genericModelSubstitutes(ResponseEntity.class).forCodeGeneration(true) .genericModelSubstitutes(ResponseEntity.class) .directModelSubstitute(java.time.LocalDate.class, String.class) .directModelSubstitute(java.time.ZonedDateTime.class, Date.class) .directModelSubstitute(java.time.LocalDateTime.class, Date.class).select() .paths(regex(DEFAULT_INCLUDE_PATTERN)).build(); watch.stop(); return docket; }
From source file:camel.Main.java
private static void testBatchOfMessages(final ProducerTemplate template, int number, int batch) throws Exception { StopWatch stopWatch = new StopWatch(); stopWatch.start();//from ww w .ja va 2s. co m for (int i = 0; i < number; i++) { template.requestBody(String.valueOf(i)); } stopWatch.stop(); System.out.println(batch + ". Exchanged " + number + " messages in " + stopWatch.getTotalTimeMillis()); }
From source file:net.sf.gazpachoquest.aspects.ProfilingAdvise.java
public Object doProfiling(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable { String taskName = createTaskName(proceedingJoinPoint); StopWatch taskTimer = new StopWatch(); try {/* ww w. j a v a 2 s.c om*/ taskTimer.start(taskName); return proceedingJoinPoint.proceed(); } finally { taskTimer.stop(); doLogging(taskTimer.getLastTaskInfo()); } }
From source file:com.baocy.tut2.Tut2Receiver.java
@RabbitHandler public void receive(String in) throws InterruptedException { StopWatch watch = new StopWatch(); watch.start();// ww w . ja va 2 s . com System.out.println("instance " + this.instance + " [x] Received '" + in + "'"); doWork(in); watch.stop(); System.out.println("instance " + this.instance + " [x] Done in " + watch.getTotalTimeSeconds() + "s"); }