Skip to content

Instantly share code, notes, and snippets.

@diegolovison
Created June 25, 2025 17:56
Show Gist options
  • Select an option

  • Save diegolovison/b650e69c753a3a1f65529409007d2091 to your computer and use it in GitHub Desktop.

Select an option

Save diegolovison/b650e69c753a3a1f65529409007d2091 to your computer and use it in GitHub Desktop.
jfr_visualizer.md
# setup
import pandas as pd
import io
import subprocess
import matplotlib.pyplot as plt

!wget -nc https://github.com/parttimenerd/jfr-query-experiments/releases/download/snapshot/query.jar
def query_and_to_dataframe(select_value):
    command = [
        "/home/dlovison/.sdkman/candidates/java/24.0.1-tem/bin/java",
        "-jar",
        "query.jar",
        "query",
        str(select_value),
        "/home/dlovison/Downloads/bkp2/bkp/profiling-data/data.jfr"
    ]

    result = subprocess.run(command, capture_output=True, text=True, check=True)
    output_string = result.stdout
    df = pd.read_csv(
        io.StringIO(output_string),
        sep=r'\s{2,}',
        engine='python',
        skiprows=[1] # Skip the separator line (index 1)
    )
    df.columns = df.columns.str.strip()
    return df
df = query_and_to_dataframe("SELECT * FROM CPULoad")
df.tail(10)
Time JVM User JVM System Machine Total
49 17:34:15 14.54% 2.17% 17.19%
50 17:34:16 14.48% 2.18% 17.17%
51 17:34:17 14.56% 2.13% 17.17%
52 17:34:18 14.46% 2.24% 17.19%
53 17:34:19 14.39% 2.30% 17.16%
54 17:34:20 14.36% 2.34% 17.18%
55 17:34:21 14.37% 2.26% 17.08%
56 17:34:22 14.22% 2.32% 17.02%
57 17:34:23 14.24% 2.30% 17.08%
58 17:34:24 14.15% 2.26% 16.84%
df['Machine Total'].str.replace('%', '').astype(float).plot()
df['JVM User'].str.replace('%', '').astype(float).plot()
df['JVM System'].str.replace('%', '').astype(float).plot()

jfr_visualizer_3_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment