Hell to Spring AOP : performance Jamon
来源:互联网 发布:简明python教程如何 编辑:程序博客网 时间:2024/05/22 00:22
前言
公司一项目为web型项目,其中一个页面打开花上8-9seconds。要优化,必须的。
首先要找到优化的点所在。在方法开始和结尾处分别使用System.currentTimeMillis(),然后相减固然能得到函数的调用时间。
或者使用cassandra中的latency tracker,都可以。
大哥,你是知道的,我喜欢玩点花活,刚好项目中使用了Spring,所以考虑到了AOP
Action
JamonPerformanceMonitorInterceptor
spring中已经有tracer和monitor:JamonPerformanceMonitorInterceptor
似乎直接用即可,但我不熟悉Jamon,一眼看去,似乎只要简单的start, stop即可.由于我想在eclipse中控制台直接查看结果,
又没有配置Log4j,所以写了简单的wrapper类
配置文件 applicationContext.xml
<bean id="performanceMonitorInterceptor" class="org.leef.spring.OurJamonPerformanceMonitorInterceptor">
<aop:config proxy-target-class="false">
<aop:pointcut id="operationPointCut" expression="execution(* org.leef.dao.EventDAO.*(..))" />
<aop:advisor advice-ref="performanceMonitorInterceptor" pointcut-ref="operationPointCut" order="1"/>
</aop:config>
问题1 只有public private 方法能被代理,监控
在网络上搜索一番后,AspectJ Load-time Weaving in Spring, AspectJ可以代理任何public, protected, private方法,于是乎仿照例子,写了个Advice
配置文件
applicationContext.xml
<context:load-time-weaver aspectj-weaving="on" />
aop.xml
放在meta-inf目录下
注意在
- weaver中将advice本身所在的包也要包含进去,否则
java.lang.NoSuchMethodError: org.leef.common.PerformanceAdvice.aspectOf()
- 启动包含有aspectj-weaving时,必须要加入vm 参数 -javaagent:/path/to/jar/spring-agent.jar
spring3.0中是-javaagent:/path/to/jar/spring-instrument.jar
java.lang.IllegalStateException: ClassLoader [sun.misc.Launcher$AppClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar
好了,这就是我的第一个AOP。
同样的,关于AOP的故事,还有很多。。。
- Hell to Spring AOP : performance Jamon
- Rose, Hell, Performance, Drawn
- Jamon
- Go to hell !!!
- Table Layouts vs. Div Layouts: From Hell to… Hell?
- Hell
- JAMon Introduction
- From hell to Paradise,but then back to hell,but last to paradise
- hell--hell
- 优化程序之前,可用Jamon来监测你的Spring应用
- 优化程序之前,可用Jamon来监测你的Spring应用
- Approaches to Performance Testing
- Spring Boot Memory Performance
- Spring Boot Memory Performance
- AOP、Spring的AOP
- AOP--Spring AOP
- Spring AOP 嵌套AOP
- spring AOP
- 获取图片工具类
- tput、set
- 《Windows核心编程》第7章 线程调度、优先级和关联性
- 第一篇博客
- 《Windows核心编程》第8章 用户模式下的线程同步
- Hell to Spring AOP : performance Jamon
- iphone
- 什么是android appwidget?
- Log4j的一个配置
- 编程技巧:document.execCommand()用法详解
- timer 和 ScheduledThreadExecutor定时
- 并发编程—— Java 内建线程机制【下】
- 对Spring的Ioc的一些理解
- Creating Release Keys and Signing Builds