- System requirements
- Profiler architecture
- Running the profiler
- Profiler activation
- Start profiling
- Solving performance problems
- CPU profiling
- Threads
- Deadlock detector
- Memory profiling
- Garbage collection
- Monitor profiling
- Exception profiling
- Probes: monitor events of various kinds
- Events in user interface
- Event inspections
- Built-in probes
- Probe classes
- Monitoring method invocation events
- Probe class annotation @MethodPattern
- Callback onEnter()
- Callback onReturn()
- Callbacks onUncaughtException() and onUncaughtExceptionExt()
- Parameter annotation @Param
- Parameter annotation @Params
- Parameter annotation @This
- Parameter annotation @ClassRef
- Parameter annotation @MethodName
- Parameter annotation @MethodParameterTypes
- Parameter annotation @MethodSignature
- Parameter annotation @OnEnterResult
- Parameter annotation @ReturnValue
- Parameter annotation @ThrownException
- Probe application rules
- Data storage
- Performance Charts
- Inspections: automatic recognition of typical problems
- Automatically trigger actions on event
- Summary, snapshot annotation, automatic deobfuscation
- Time measurement (CPU time, wall time)
- Filters
- Snapshot directory customization
- Export of profiling results to HTML, CSV, XML, plain text
- Profiler Java API
- Profiler HTTP API
- Command line tool to control profiling
- Settings
- FAQ: How to profile in my scenario?
Probe class annotation @MethodPattern
Probe class must be annotated with @MethodPattern
annotation
in order to specify which methods the callbacks will be applied to.
One or more method patterns can be specified in the following format ('*' wildcard is allowed):
class_name : method_name ( parameter_types )
You can optionally specify that class or method must have particular annotations.
Put @annotation
before the class and/or the method pattern accordingly:
[@class_annotation] class_name : [@method_annotation] method_name ( parameter_types )
Part | Description | Examples |
class_name |
Full qualified class name, dot-separated. Inner class part(s) are separated with "$" sign. |
Particular class:
Class with name ending with 'Helper':
Any class in a package:
Any class: |
class_annotation (optional) |
Specify that matching classes must have particular annotation. If not specified, class with any annotations or with no annotations at all will match. |
All |
method_name |
Method name.
To specify a constructor, use <init> .
|
Method with particular name:
Any getter:
Any method, including constructors: |
method_annotation (optional) |
Specify that matching methods must have particular annotation. If not specified, methods with any annotations or with no annotations at all will match. |
All JUnit tests: |
parameter_types |
Comma-separated list of parameter types. Space characters between type names and commas are allowed (but not required).
Class names should be full qualified, dot-separated,
except for
Primitive types should be named as in Java source code:
Arrays are specified as Use empty string to specify a method with no parameters.
|
No parameters: empty
Any number of parameters, including zero:
3 parameters of particular types:
First parameter is an array of class com.Foo:
|
The annotation is declared as...
package com.yourkit.probes;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
public @interface MethodPattern {
String[] value();
}
...and specifies one or more patterns for a probe. For example:
import com.yourkit.probes.*;
// Instrument calls of method 'findPerson' in class 'com.foo.Person', which has 2 parameters of particular types
@MethodPattern("com.foo.Person:findPerson(String, int)")
public class MyProbe1 {
//...
}
// Instrument all methods in classes 'com.Foo' and 'com.Bar'
@MethodPattern(
{
// should match at least one of them
"com.Foo:*(*)",
"com.Bar:*(*)"
}
)
public class MyProbe2 {
//...
}
// Instrument methods toString() in all classes in package com.foo
@MethodPattern("com.foo.*:toString()")
public class MyProbe3 {
//...
}
// Instrument all methods in classes whose names end with 'Helper' and have int[][] as a first parameter
@MethodPattern("*Helper:(int[][],*)")
public class MyProbe4 {
//...
}