public static void premain(String args, Instrumentation instrumentation)
@SuppressWarnings("unused") public static void methodEnter(MethodInfo methodInfo) { methodCallProcessor.methodEnter(methodInfo); } @SuppressWarnings("unused") public static void methodExit() { methodCallProcessor.methodExit(); }
public class ShadowClassXXX { public static MethodInfo m1 = agent.TracerAgent.getMethodInfo(1L); // MethodInfo /* .. */ public static MethodInfo m99 = agent.TracerAgent.getMethodInfo(99L); // MethodInfo }
TracerAgent.methodEnter(ShadowClass.mXXX);
TracerAgent.methodExit();
Options: -javaagent: <full path to the agent jar file> = p: regexp [#t: regexp] [# d: number] [# i: number] p - instrumented classes (full match - match) t - traced methods (partial match - find) d - debug level i - statistics output period in seconds (0 disables periodic output)
java -version java version "1.7.0_21" Java(TM) SE Runtime Environment (build 1.7.0_21-b11) Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode) java -XX:-UseSplitVerifier -javaagent:D:\traceragent\target\traceragent-1.0-SNAPSHOT-complete.jar=p:examples.*#d:1#i:5
[AGENT +] *** performance report *** Top 5 time consuming methods (microseconds): 965050 examples.data.CashAccountRow $ masks.access $ 100 (examples.data.CashAccountRow $ masks) 779944 examples.data.CashAccountRow.setAge (int) 766023 examples.data.CashAccountRow.setGender (int) 764292 examples.data.CashAccountRow.setHeight (int) 763387 examples.data.CashAccountRow.setAmount (int) Top 5 called methods: 22805261 examples.data.CashAccountRow $ masks.access $ 100 (examples.data.CashAccountRow $ masks) 9122242 examples.data.CashAccountRow $ shifts.access $ 000 (examples.data.CashAccountRow $ shifts) 2280592 examples.data.CashAccountRow.setAge (int) 2280623 examples.data.CashAccountRow.setBitStorage (long) 2280653 examples.data.CashAccountRow.setGender (int) Top 5 objects constructed: 1 examples.data.CashAccountStore 1 examples.data.CashAccountRow [AGENT-] *** end of performance report *** --- skip --- Number of records matched: 38 Elapsed time: 7707ms Used Memory: 91MB [AGENT +] *** performance report *** Top 10 time consuming methods (microseconds): 36081913 examples.App.main (java.lang.String []) 20606259 examples.data.CashAccountStore () 15428502 examples.data.CashAccountStore.find2 (examples.data.CashAccountStore $ CashAccountFinder) 12439241 examples.data.GenMatcherAMOUNTHEIGHTGENDER.c (examples.data.CashAccountRow) 9469502 examples.data.CashAccountRow.getAmount () 5928018 examples.data.CashAccountRow $ masks.access $ 100 (examples.data.CashAccountRow $ masks) 3392146 examples.data.CashAccountRow $ shifts.access $ 000 (examples.data.CashAccountRow $ shifts) 3279163 examples.data.CashAccountRow.setAge (int) 3271959 examples.data.CashAccountRow.setHeight (int) 3267890 examples.data.CashAccountRow.setAmount (int) Top 10 called methods: 140079808 examples.data.CashAccountRow $ masks.access $ 100 (examples.data.CashAccountRow $ masks) 80079812 examples.data.CashAccountRow $ shifts.access $ 000 (examples.data.CashAccountRow $ shifts) 40000000 examples.data.CashAccountRow.getAmount () 30000000 examples.data.CashAccountRow.setBitStorage (long) 20000000 examples.data.GenMatcherAMOUNTHEIGHTGENDER.c (examples.data.CashAccountRow) 10,000,000 examples.data.CashAccountRow.setGender (int) 10,000,000 examples.data.CashAccountRow.setAge (int) 10,000,000 examples.data.CashAccountRow.setAmount (int) 10,000,000 examples.data.CashAccountRow.setHeight (int) 10,000,000 examples.data.CashAccountRow.getBitStorage () Top 10 objects constructed: 3 examples.data.CashAccountStore $ CashAccountFinder $ FieldGetter 3 examples.data.CashAccountStore $ CashAccountFinder $ PredicateHolder 3 examples.data.CashAccountRow 1 examples.data.GenMatcherAMOUNTHEIGHTGENDER 1 examples.data.GenMatcherBase 1 examples.data.CashAccountStore $ CashAccountFinder $ HeightFieldGetter 1 examples.data.CashAccountStore $ CashAccountFinder 1 examples.data.CashAccountStore 1 examples.data.CashAccountStore $ CashAccountFinder $ AmountFieldGetter 1 examples.data.CashAccountStore $ CashAccountFinder $ GenderFieldGetter [AGENT-] *** end of performance report ***
Source: https://habr.com/ru/post/185010/
All Articles