-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
begin seperation of parser from model
- Loading branch information
Haim Yadid
committed
Dec 8, 2022
1 parent
89ff079
commit c66c4f2
Showing
6 changed files
with
52 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/com/performizeit/mjprof/parser/ThreadDumpTextualParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.performizeit.mjprof.parser; | ||
|
||
import com.performizeit.mjprof.model.JStackHeader; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class ThreadDumpTextualParser { | ||
public static String JNI_GLOBAL_REFS = "JNI global references:"; | ||
|
||
public static ThreadDump parseStringRepresentation (String stringRep) { | ||
String[] splitTraces = stringRep.split("\n\""); // Assuming that thread stack trace starts with a new line followed by " | ||
int JNIglobalReferences = -1; | ||
JStackHeader header = new JStackHeader(splitTraces[0]); | ||
ArrayList<ThreadInfo> threadInfos = new ArrayList<>(); | ||
for (int i = 1; i < splitTraces.length; i++) { | ||
if (splitTraces[i].startsWith(JNI_GLOBAL_REFS)) { | ||
try { | ||
JNIglobalReferences = Integer.parseInt(splitTraces[i].substring(splitTraces[i].indexOf(":") + 2).trim()); | ||
} catch (NumberFormatException e) { | ||
// do nothing so we missed the JNI global references I do not know what to do with it. | ||
} | ||
|
||
} else { | ||
threadInfos.add(new ThreadInfo("\"" + splitTraces[i])); | ||
} | ||
} | ||
return new ThreadDump(header,threadInfos,JNIglobalReferences); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters