Search in sources :

Example 1 with StackTraceReader

use of org.gridkit.jvmtool.stacktrace.StackTraceReader in project jvm-tools by aragozin.

the class FlameCheck method check.

@Test
public void check() throws IOException {
    FlameGraphGenerator fg = new FlameGraphGenerator();
    StackTraceReader r = read();
    if (!r.isLoaded()) {
        r.loadNext();
    }
    while (r.isLoaded()) {
        fg.feed(r.getStackTrace());
        r.loadNext();
    }
    StringWriter sw = new StringWriter();
    fg.renderSVG("Flame Graph", 1200, sw);
    FileWriter fw = new FileWriter(new File("target/flame.svg"));
    fw.append(sw.getBuffer());
    fw.close();
}
Also used : StringWriter(java.io.StringWriter) FileWriter(java.io.FileWriter) StackTraceReader(org.gridkit.jvmtool.stacktrace.StackTraceReader) File(java.io.File) FlameGraphGenerator(org.gridkit.jvmtool.stacktrace.analytics.flame.FlameGraphGenerator) Test(org.junit.Test)

Example 2 with StackTraceReader

use of org.gridkit.jvmtool.stacktrace.StackTraceReader in project jvm-tools by aragozin.

the class FilterParserCorpusTest method verify.

@Test
public void verify() throws FileNotFoundException, IOException {
    ThreadSnapshotFilter f = TraceFilterPredicateParser.parseFilter(filter, new CachingFilterFactory());
    StackTraceReader reader = StackTraceCodec.newReader(new FileInputStream("src/test/resources/jboss-10k.std"));
    int n = 0;
    if (!reader.isLoaded()) {
        reader.loadNext();
    }
    ThreadSnapshot readerProxy = new ReaderProxy(reader);
    while (reader.isLoaded()) {
        if (f.evaluate(readerProxy)) {
            ++n;
        }
        if (!reader.loadNext()) {
            break;
        }
    }
    Assert.assertEquals(matchCount, n);
}
Also used : ReaderProxy(org.gridkit.jvmtool.stacktrace.ReaderProxy) ThreadSnapshot(org.gridkit.jvmtool.stacktrace.ThreadSnapshot) StackTraceReader(org.gridkit.jvmtool.stacktrace.StackTraceReader) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

StackTraceReader (org.gridkit.jvmtool.stacktrace.StackTraceReader)2 Test (org.junit.Test)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileWriter (java.io.FileWriter)1 StringWriter (java.io.StringWriter)1 ReaderProxy (org.gridkit.jvmtool.stacktrace.ReaderProxy)1 ThreadSnapshot (org.gridkit.jvmtool.stacktrace.ThreadSnapshot)1 FlameGraphGenerator (org.gridkit.jvmtool.stacktrace.analytics.flame.FlameGraphGenerator)1