Skip to content

Commit

Permalink
move ProfileNodeFilter to plugins package
Browse files Browse the repository at this point in the history
  • Loading branch information
Haim Yadid committed Dec 8, 2022
1 parent c66c4f2 commit f572009
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/performizeit/mjprof/model/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package com.performizeit.mjprof.model;

import com.performizeit.mjprof.plugins.filters.ProfileNodeFilter;

import java.util.HashMap;


Expand Down Expand Up @@ -72,9 +74,7 @@ public void addSingle(StackTraceElement[] elements) {
HashMap<String,SFNode> c = root.children;
root.count ++;
for (int i=elements.length-1;i>=0;i--) {

String sfi = "at "+ elements[i].getClassName() + "." +elements[i].getMethodName() +"("+elements[i].getFileName()+":"+elements[i].getLineNumber()+")";
if (sfi.isEmpty()) continue;
SFNode node = c.get(sfi);
if (node == null) {
node = new SFNode();
Expand Down Expand Up @@ -133,7 +133,7 @@ public void visit(ProfileVisitor pv) {
root.visitChildren(pv,0);
}

public void filter(ProfileNodeFilter pnf,Object context) {
public void filter(ProfileNodeFilter pnf, Object context) {
root.filterChildren(pnf,0,context);
}
public int getCount() {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/performizeit/mjprof/model/SFNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package com.performizeit.mjprof.model;

import com.performizeit.mjprof.plugins.filters.ProfileNodeFilter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -275,4 +277,4 @@ public int depthBelow() {
return depthB;
}

}
}
7 changes: 3 additions & 4 deletions src/main/java/com/performizeit/mjprof/parser/ThreadDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public ThreadDump(JStackHeader header, ArrayList<ThreadInfo> threadInfos) {

}


public ThreadDump() {
}

Expand Down Expand Up @@ -83,9 +82,9 @@ public void setHeader(JStackHeader header) {
}

public ArrayList<ThreadInfo> cloneStacks() {
ArrayList<ThreadInfo> newStcks = new ArrayList<>();
newStcks.addAll(getThreadInfos());
return newStcks;
ArrayList<ThreadInfo> newStacks = new ArrayList<>();
newStacks.addAll(getThreadInfos());
return newStacks;
}

public int getJNIglobalReferences() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
along with mjprof. If not, see <http://www.gnu.org/licenses/>.
*/

package com.performizeit.mjprof.model;
package com.performizeit.mjprof.plugins.filters;

public interface ProfileNodeFilter {
boolean accept(SFNode node, int level,Object context);
import com.performizeit.mjprof.model.SFNode;

public interface ProfileNodeFilter {
boolean accept(SFNode node, int level, Object context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import com.performizeit.mjprof.api.Plugin;
import com.performizeit.mjprof.api.PluginCategory;
import com.performizeit.mjprof.model.Profile;
import com.performizeit.mjprof.model.ProfileNodeFilter;
import com.performizeit.mjprof.model.SFNode;
import com.performizeit.mjprof.api.Param;
import com.performizeit.mjprof.parser.ThreadInfo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import com.performizeit.mjprof.api.Plugin;
import com.performizeit.mjprof.api.PluginCategory;
import com.performizeit.mjprof.model.Profile;
import com.performizeit.mjprof.model.ProfileNodeFilter;
import com.performizeit.mjprof.model.SFNode;
import com.performizeit.mjprof.api.Param;
import com.performizeit.mjprof.parser.ThreadInfo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.performizeit.mjprof.api.Plugin;
import com.performizeit.mjprof.api.PluginCategory;
import com.performizeit.mjprof.model.Profile;
import com.performizeit.mjprof.model.ProfileNodeFilter;
import com.performizeit.mjprof.plugins.filters.ProfileNodeFilter;
import com.performizeit.mjprof.model.SFNode;
import com.performizeit.mjprof.api.Param;
import com.performizeit.mjprof.parser.ThreadInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.performizeit.mjprof.plugin.types.SingleThreadMapper;
import com.performizeit.mjprof.api.Plugin;
import com.performizeit.mjprof.model.Profile;
import com.performizeit.mjprof.model.ProfileNodeFilter;
import com.performizeit.mjprof.plugins.filters.ProfileNodeFilter;
import com.performizeit.mjprof.model.SFNode;
import com.performizeit.mjprof.api.Param;
import com.performizeit.mjprof.parser.ThreadInfo;
Expand All @@ -39,13 +39,9 @@ public ThreadInfo map(ThreadInfo stck) {
HashMap<String,Object> mtd = stck.cloneMetaData();
Profile jss = (Profile) mtd.get("stack");

jss.filter(new ProfileNodeFilter() {

@Override
public boolean accept(SFNode node, int level, Object context) {
if (node.getStackFrame() == null) return true;
return node.getStackFrame().contains("lock");
}
jss.filter((node, level, context) -> {
if (node.getStackFrame() == null) return true;
return node.getStackFrame().contains("lock");
},null);
return stck;
}
Expand Down

0 comments on commit f572009

Please sign in to comment.