JProfiler 9.2及以上版本能否忽略匹配类同签名方法?求配置方案
Absolutely, you can ignore methods with specific signatures (like hashCode() and equals()) across any class in JProfiler 9.2 and newer. This is a core feature built to help you focus on meaningful hotspots without cluttering your data with noise from universally implemented methods. Here's how to set it up:
Step-by-Step Configuration
1. Open Session Settings
Either create a new profiling session or open an existing one. Go to Session > Session Settings (use Ctrl+Shift+S on Windows/Linux, Cmd+Shift+S on macOS as a shortcut).
2. Navigate to Instrumentation Rules
In the settings window, expand the Instrumentation section and select Method Patterns. This is where you define which methods to include or exclude from instrumentation.
3. Add Exclusion Rules for hashCode() and equals()
- Click the green Add button to create a new rule.
- In the "Class pattern" field, enter
*— this matches every class in your application. - In the "Method pattern" field, enter the full method signature for the method you want to ignore:
- For
hashCode():public int hashCode() - For
equals():public boolean equals(java.lang.Object)
- For
- Set the Action dropdown to Exclude (this tells JProfiler not to instrument these methods).
- Repeat this process for both methods to create two separate exclusion rules.
4. Make the Rule Default (Optional)
If you want this exclusion to apply to all future profiling sessions automatically:
- After setting up the rules in Session Settings, click the Save as Default button at the bottom of the window.
- Alternatively, go to Window > Global Settings, navigate to Default Session Settings > Instrumentation > Method Patterns, and add the same exclusion rules there.
Additional Notes
- Rule Priority: Exclusion rules take precedence over inclusion rules, so even if you have other patterns that would match these methods, the exclusion will override them.
- Existing Sessions: If you're modifying a running session, you'll need to restart the profiling session for the new rules to take effect.
- Wildcards: You can use wildcards in method patterns if you need to ignore broader sets of methods. For example,
public * get*()would ignore all getter methods, but for your specific use case, exact signatures are best to avoid accidental exclusions.
内容的提问来源于stack exchange,提问作者Brian

