├── README.md ├── pom.xml └── src └── main ├── java └── org │ └── iamzhongyong │ └── profiler │ ├── Profiler.java │ ├── ProfilerAnno.java │ ├── ProfilerApsect.java │ ├── ProfilerSwitch.java │ └── test │ ├── ProfilerAopTest.java │ ├── ProfilerTest.java │ └── biz │ └── ProfilerBizService.java └── resources ├── application.xml └── log4j.xml /README.md: -------------------------------------------------------------------------------- 1 | treeProfiler 2 | ============ 3 | 4 | 监控应用程序,埋点,打印树状结构 5 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | org.iamzhongyong 4 | treeProfile 5 | 0.0.1-SNAPSHOT 6 | 7 | 8 | org.springframework 9 | spring-core 10 | 3.2.3.RELEASE 11 | 12 | 13 | org.springframework.batch 14 | spring-batch-core 15 | 2.2.0.RELEASE 16 | 17 | 18 | org.springframework 19 | spring-aspects 20 | 3.2.3.RELEASE 21 | 22 | 23 | aspectj 24 | aspectjrt 25 | 1.6.1 26 | 27 | 28 | org.slf4j 29 | slf4j-api 30 | 1.6.1 31 | 32 | 33 | org.slf4j 34 | slf4j-log4j12 35 | 1.6.1 36 | 37 | 38 | log4j 39 | log4j 40 | 1.2.14 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/main/java/org/iamzhongyong/profiler/Profiler.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamzhongyong/treeProfiler/e21c80c5eb723e044cc2afd9d4446feb53a1792b/src/main/java/org/iamzhongyong/profiler/Profiler.java -------------------------------------------------------------------------------- /src/main/java/org/iamzhongyong/profiler/ProfilerAnno.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamzhongyong/treeProfiler/e21c80c5eb723e044cc2afd9d4446feb53a1792b/src/main/java/org/iamzhongyong/profiler/ProfilerAnno.java -------------------------------------------------------------------------------- /src/main/java/org/iamzhongyong/profiler/ProfilerApsect.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamzhongyong/treeProfiler/e21c80c5eb723e044cc2afd9d4446feb53a1792b/src/main/java/org/iamzhongyong/profiler/ProfilerApsect.java -------------------------------------------------------------------------------- /src/main/java/org/iamzhongyong/profiler/ProfilerSwitch.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamzhongyong/treeProfiler/e21c80c5eb723e044cc2afd9d4446feb53a1792b/src/main/java/org/iamzhongyong/profiler/ProfilerSwitch.java -------------------------------------------------------------------------------- /src/main/java/org/iamzhongyong/profiler/test/ProfilerAopTest.java: -------------------------------------------------------------------------------- 1 | package org.iamzhongyong.profiler.test; 2 | 3 | import org.iamzhongyong.profiler.test.biz.ProfilerBizService; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.support.ClassPathXmlApplicationContext; 6 | 7 | public class ProfilerAopTest { 8 | 9 | public static void main(String[] args) throws Exception { 10 | ApplicationContext context = new ClassPathXmlApplicationContext("application.xml"); 11 | 12 | ProfilerBizService profilerBizService = (ProfilerBizService)context.getBean("profilerBizService"); 13 | 14 | profilerBizService.A(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/iamzhongyong/profiler/test/ProfilerTest.java: -------------------------------------------------------------------------------- 1 | package org.iamzhongyong.profiler.test; 2 | 3 | import org.iamzhongyong.profiler.Profiler; 4 | import org.iamzhongyong.profiler.ProfilerSwitch; 5 | 6 | public class ProfilerTest { 7 | public static void main(String[] args) { 8 | ProfilerSwitch.getInstance().setOpenProfilerNanoTime(true); 9 | ProfilerTest t = new ProfilerTest(); 10 | t.rootMethod(); 11 | } 12 | 13 | public void rootMethod(){ 14 | Profiler.start("rootMethod"); 15 | firstMethod(); 16 | Profiler.release(); 17 | System.out.println(Profiler.dump()); 18 | Profiler.reset(); 19 | 20 | } 21 | public void firstMethod(){ 22 | Profiler.enter("first"); 23 | secondMethod(); 24 | Profiler.release(); 25 | 26 | } 27 | public void secondMethod(){ 28 | Profiler.enter("second"); 29 | Profiler.release(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/iamzhongyong/profiler/test/biz/ProfilerBizService.java: -------------------------------------------------------------------------------- 1 | package org.iamzhongyong.profiler.test.biz; 2 | 3 | import org.iamzhongyong.profiler.ProfilerAnno; 4 | 5 | @ProfilerAnno 6 | public class ProfilerBizService { 7 | 8 | public void A() throws Exception{ 9 | Thread.sleep(200); 10 | A1(); 11 | System.out.println("iamzhongyong"); 12 | } 13 | public void A1() throws Exception{ 14 | Thread.sleep(200); 15 | A11(); 16 | } 17 | public void A11() throws Exception{ 18 | Thread.sleep(200); 19 | } 20 | public void A2() throws Exception{ 21 | Thread.sleep(200); 22 | A1(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/resources/application.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/resources/log4j.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamzhongyong/treeProfiler/e21c80c5eb723e044cc2afd9d4446feb53a1792b/src/main/resources/log4j.xml --------------------------------------------------------------------------------