org.springframework.util.StopWatch Java Examples
The following examples show how to use
org.springframework.util.StopWatch.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 6 votes |
@Test @Ignore // TODO re-enable when ConstructorResolver TODO sorted out public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getConstructorArgumentValues().addGenericArgumentValue("juergen"); rbd.getConstructorArgumentValues().addGenericArgumentValue("99"); lbf.registerBeanDefinition("test", rbd); lbf.freezeConfiguration(); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) lbf.getBean("test"); assertEquals("juergen", tb.getName()); assertEquals(99, tb.getAge()); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000); }
Example #2
Source File: ZipFileIterator.java From secure-data-service with Apache License 2.0 | 6 votes |
public InputStream next() { ZipArchiveEntry zipEntry = zipEntries.nextElement(); StopWatch sw = new StopWatch(zipEntry.getName()); InputStream feStream = null; try { return zipFile.getInputStream(zipEntry); } catch (IOException e) { IOUtils.closeQuietly(feStream); return null; } finally { IOUtils.closeQuietly(feStream); System.out.print(sw.prettyPrint()); } }
Example #3
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference("spouse")); lbf.registerBeanDefinition("test", rbd); lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); lbf.freezeConfiguration(); TestBean spouse = (TestBean) lbf.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) lbf.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); }
Example #4
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testPrototypeCreationIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); lbf.registerBeanDefinition("test", rbd); lbf.freezeConfiguration(); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { lbf.getBean("test"); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000); }
Example #5
Source File: BenchmarkTests.java From java-technology-stack with MIT License | 6 votes |
private long testAfterReturningAdviceWithoutJoinPoint(String file, int howmany, String technology) { ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS); StopWatch sw = new StopWatch(); sw.start(howmany + " repeated after returning advice invocations with " + technology); ITestBean adrian = (ITestBean) bf.getBean("adrian"); assertTrue(AopUtils.isAopProxy(adrian)); Advised a = (Advised) adrian; assertTrue(a.getAdvisors().length >= 3); // Hits joinpoint adrian.setAge(25); for (int i = 0; i < howmany; i++) { adrian.setAge(i); } sw.stop(); System.out.println(sw.prettyPrint()); return sw.getLastTaskTimeMillis(); }
Example #6
Source File: AbstractHttpServer.java From java-technology-stack with MIT License | 6 votes |
@Override public final void stop() { synchronized (this.lifecycleMonitor) { if (isRunning()) { String serverName = getClass().getSimpleName(); logger.debug("Stopping " + serverName + "..."); this.running = false; try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); stopInternal(); logger.debug("Server stopped (" + stopWatch.getTotalTimeMillis() + " millis)."); } catch (Throwable ex) { throw new IllegalStateException(ex); } finally { reset(); } } } }
Example #7
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testPrototypeCreationWithResolvedPropertiesIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse")); lbf.registerBeanDefinition("test", rbd); lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); lbf.freezeConfiguration(); TestBean spouse = (TestBean) lbf.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) lbf.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); }
Example #8
Source File: MapAccessTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testGetValuePerformance() throws Exception { Assume.group(TestGroup.PERFORMANCE); Map<String, String> map = new HashMap<>(); map.put("key", "value"); EvaluationContext context = new StandardEvaluationContext(map); ExpressionParser spelExpressionParser = new SpelExpressionParser(); Expression expr = spelExpressionParser.parseExpression("#root['key']"); StopWatch s = new StopWatch(); s.start(); for (int i = 0; i < 10000; i++) { expr.getValue(context); } s.stop(); assertThat(s.getTotalTimeMillis(), lessThan(200L)); }
Example #9
Source File: AnnotationProcessorPerformanceTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testPrototypeCreationWithResourcePropertiesIsFastEnough() { GenericApplicationContext ctx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx); ctx.refresh(); RootBeanDefinition rbd = new RootBeanDefinition(ResourceAnnotatedTestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) ctx.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ctx.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); }
Example #10
Source File: GenericConversionServiceTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testPerformance2() throws Exception { Assume.group(TestGroup.PERFORMANCE); StopWatch watch = new StopWatch("list<string> -> list<integer> conversionPerformance"); watch.start("convert 4,000,000 with conversion service"); List<String> source = new LinkedList<>(); source.add("1"); source.add("2"); source.add("3"); TypeDescriptor td = new TypeDescriptor(getClass().getField("list")); for (int i = 0; i < 1000000; i++) { conversionService.convert(source, TypeDescriptor.forObject(source), td); } watch.stop(); watch.start("convert 4,000,000 manually"); for (int i = 0; i < 4000000; i++) { List<Integer> target = new ArrayList<>(source.size()); for (String element : source) { target.add(Integer.valueOf(element)); } } watch.stop(); // System.out.println(watch.prettyPrint()); }
Example #11
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testSingletonLookupByTypeIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class)); lbf.freezeConfiguration(); StopWatch sw = new StopWatch(); sw.start("singleton"); for (int i = 0; i < 1000000; i++) { lbf.getBean(TestBean.class); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Singleton lookup took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 1000); }
Example #12
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testSingletonLookupByNameIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class)); lbf.freezeConfiguration(); StopWatch sw = new StopWatch(); sw.start("singleton"); for (int i = 0; i < 1000000; i++) { lbf.getBean("test"); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Singleton lookup took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 1000); }
Example #13
Source File: CallMonitoringAspect.java From DevOps-for-Web-Development with MIT License | 6 votes |
@Around("within(@org.springframework.stereotype.Repository *)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { if (this.enabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); try { return joinPoint.proceed(); } finally { sw.stop(); synchronized (this) { this.callCount++; this.accumulatedCallTime += sw.getTotalTimeMillis(); } } } else { return joinPoint.proceed(); } }
Example #14
Source File: DefaultConversionServiceTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testPerformance1() { Assume.group(TestGroup.PERFORMANCE); StopWatch watch = new StopWatch("integer->string conversionPerformance"); watch.start("convert 4,000,000 with conversion service"); for (int i = 0; i < 4000000; i++) { conversionService.convert(3, String.class); } watch.stop(); watch.start("convert 4,000,000 manually"); for (int i = 0; i < 4000000; i++) { Integer.valueOf(3).toString(); } watch.stop(); // System.out.println(watch.prettyPrint()); }
Example #15
Source File: AbstractHttpServer.java From spring-cloud-gateway with Apache License 2.0 | 6 votes |
@Override public final void stop() { synchronized (this.lifecycleMonitor) { if (isRunning()) { String serverName = getClass().getSimpleName(); logger.debug("Stopping " + serverName + "..."); this.running = false; try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); stopInternal(); logger.debug("Server stopped (" + stopWatch.getTotalTimeMillis() + " millis)."); } catch (Throwable ex) { throw new IllegalStateException(ex); } finally { reset(); } } } }
Example #16
Source File: MiniCubeTest.java From minicubes with Apache License 2.0 | 6 votes |
@Test public void test_5_2_DistinctCount_20140606() throws Throwable { StopWatch stopWatch = new StopWatch(); stopWatch.start(); Map<String, List<Integer>> filter = new HashMap<String, List<Integer>>(1); filter.put("tradeId", Arrays.asList(new Integer[] { 3205, 3206, 3207, 3208, 3209, 3210, 3212, 3299, 3204, 3203, 3202, 3201, 3211})); Map<Integer, RoaringBitmap> distinct = miniCube.distinct("postId", true, "tradeId", filter); stopWatch.stop(); Assert.assertEquals(13, distinct.size()); Assert.assertEquals(277, distinct.get(3209).getCardinality()); Assert.assertEquals(186, distinct.get(3211).getCardinality()); Assert.assertEquals(464, distinct.get(3206).getCardinality()); LOGGER.info(stopWatch.getTotalTimeSeconds() + " used for distinct result {}", distinct.toString()); }
Example #17
Source File: MapAccessTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testGetValuePerformance() throws Exception { Assume.group(TestGroup.PERFORMANCE); Map<String, String> map = new HashMap<>(); map.put("key", "value"); EvaluationContext context = new StandardEvaluationContext(map); ExpressionParser spelExpressionParser = new SpelExpressionParser(); Expression expr = spelExpressionParser.parseExpression("#root['key']"); StopWatch s = new StopWatch(); s.start(); for (int i = 0; i < 10000; i++) { expr.getValue(context); } s.stop(); assertThat(s.getTotalTimeMillis(), lessThan(200L)); }
Example #18
Source File: AnnotationProcessorPerformanceTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testPrototypeCreationWithOverriddenAutowiredPropertiesIsFastEnough() { GenericApplicationContext ctx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx); ctx.refresh(); RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse")); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) ctx.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ctx.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 6000); }
Example #19
Source File: SnomedTaxonomyBuilder.java From snomed-owl-toolkit with Apache License 2.0 | 6 votes |
public SnomedTaxonomy buildWithAxiomRefset(InputStreamSet snomedRf2OwlSnapshotArchive) throws ReleaseImportException { StopWatch stopWatch = new StopWatch(); stopWatch.start(); SnomedTaxonomyLoader snomedTaxonomyLoader = new SnomedTaxonomyLoader(); ReleaseImporter releaseImporter = new ReleaseImporter(); releaseImporter.loadEffectiveSnapshotReleaseFileStreams(snomedRf2OwlSnapshotArchive.getFileInputStreams(), OWL_SNAPSHOT_LOADING_PROFILE, snomedTaxonomyLoader); snomedTaxonomyLoader.reportErrors(); logger.info("Loaded release snapshot"); logger.info("Time taken deserialising axioms {}s", (snomedTaxonomyLoader.getTimeTakenDeserialisingAxioms() / 1000.00)); stopWatch.stop(); logger.info("SnomedTaxonomy loaded in {} seconds", stopWatch.getTotalTimeSeconds()); SnomedTaxonomy snomedTaxonomy = snomedTaxonomyLoader.getSnomedTaxonomy(); logger.info("{} concepts loaded", snomedTaxonomy.getAllConceptIds().size()); logger.info("{} active axioms loaded", snomedTaxonomy.getAxiomCount()); return snomedTaxonomy; }
Example #20
Source File: AnnotationProcessorPerformanceTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testPrototypeCreationWithAutowiredPropertiesIsFastEnough() { GenericApplicationContext ctx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx); ctx.refresh(); RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) ctx.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ctx.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); }
Example #21
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testPrototypeCreationWithDependencyCheckIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS); lbf.registerBeanDefinition("test", rbd); lbf.addBeanPostProcessor(new LifecycleBean.PostProcessor()); lbf.freezeConfiguration(); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { lbf.getBean("test"); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000); }
Example #22
Source File: BenchmarkTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
private long testBeforeAdviceWithoutJoinPoint(String file, int howmany, String technology) { ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS); StopWatch sw = new StopWatch(); sw.start(howmany + " repeated before advice invocations with " + technology); ITestBean adrian = (ITestBean) bf.getBean("adrian"); assertTrue(AopUtils.isAopProxy(adrian)); Advised a = (Advised) adrian; assertTrue(a.getAdvisors().length >= 3); assertEquals("adrian", adrian.getName()); for (int i = 0; i < howmany; i++) { adrian.getName(); } sw.stop(); System.out.println(sw.prettyPrint()); return sw.getLastTaskTimeMillis(); }
Example #23
Source File: AnnotationProcessorPerformanceTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testPrototypeCreationWithOverriddenAutowiredPropertiesIsFastEnough() { GenericApplicationContext ctx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx); ctx.refresh(); RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse")); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) ctx.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ctx.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 6000); }
Example #24
Source File: AnnotationProcessorPerformanceTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testPrototypeCreationWithAutowiredPropertiesIsFastEnough() { GenericApplicationContext ctx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx); ctx.refresh(); RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) ctx.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ctx.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); }
Example #25
Source File: CallMonitoringAspect.java From java-microservice with MIT License | 6 votes |
@Around("@annotation(com.apssouza.monitoring.Monitored)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { System.out.println("callend"); Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); if (this.enabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); try { return joinPoint.proceed(); } finally { sw.stop(); synchronized (this) { this.callCount++; this.accumulatedCallTime += sw.getTotalTimeMillis(); } publisher.publishEvent(new MonitoringInvokedEvent( method.getName(), this.accumulatedCallTime )); } } else { return joinPoint.proceed(); } }
Example #26
Source File: AnnotationProcessorPerformanceTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testPrototypeCreationWithResourcePropertiesIsFastEnough() { GenericApplicationContext ctx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx); ctx.refresh(); RootBeanDefinition rbd = new RootBeanDefinition(ResourceAnnotatedTestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) ctx.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ctx.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); }
Example #27
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference("spouse")); lbf.registerBeanDefinition("test", rbd); lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); lbf.freezeConfiguration(); TestBean spouse = (TestBean) lbf.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) lbf.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); }
Example #28
Source File: BenchmarkTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
private long testAfterReturningAdviceWithoutJoinPoint(String file, int howmany, String technology) { ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS); StopWatch sw = new StopWatch(); sw.start(howmany + " repeated after returning advice invocations with " + technology); ITestBean adrian = (ITestBean) bf.getBean("adrian"); assertTrue(AopUtils.isAopProxy(adrian)); Advised a = (Advised) adrian; assertTrue(a.getAdvisors().length >= 3); // Hits joinpoint adrian.setAge(25); for (int i = 0; i < howmany; i++) { adrian.setAge(i); } sw.stop(); System.out.println(sw.prettyPrint()); return sw.getLastTaskTimeMillis(); }
Example #29
Source File: DownloadController.java From NetworkDisk_Storage with GNU General Public License v2.0 | 5 votes |
/** * 下载文件 * * @author: quhailong * @date: 2019/9/25 */ //@RequestMapping(value = "/download", method = RequestMethod.POST) @RequestMapping(value = "download", method = RequestMethod.GET) public void download(String uid, String vids, HttpServletResponse res) throws IOException { logger.info("下载文件请求URL:{}", httpServletRequest.getRequestURL()); StopWatch stopWatch = new StopWatch(); stopWatch.start(); logger.info("下载文件数据处理开始,vids:{}", vids); downloadProvider.downloadHandle(uid, vids, res); logger.info("下载文件数据处理结束"); stopWatch.stop(); logger.info("下载文件调用时间,millies:{}", stopWatch.getTotalTimeMillis()); }
Example #30
Source File: AbstractJobDispatcher.java From chronus with Apache License 2.0 | 5 votes |
protected void printSelectTaskMonitorLog(StopWatch clock, int size, boolean resultFlag) { clock.stop(); getMonitorLogger().info(MONITOR_LOGGER_PATTERN_SELECT_TASKS, jobConfig.getSysCode(), jobConfig.getTaskName(), jobConfig.getBeanName(), ContextLog4j2Util.getRequestNo(), RpcContext.getContext().getRemoteHost(), size, resultFlag ? Response.SUCC : Response.FAIL, clock.getTotalTimeMillis()); }