mirror of
https://github.com/simon987/toolbox.git
synced 2025-04-10 14:06:42 +00:00
tweak graph style
This commit is contained in:
parent
1bb466762f
commit
effc30c991
@ -32,7 +32,7 @@ def flame_graph_get(key: str):
|
|||||||
return Response(content=data, media_type="image/svg+xml")
|
return Response(content=data, media_type="image/svg+xml")
|
||||||
|
|
||||||
@app.post("/flame_graph")
|
@app.post("/flame_graph")
|
||||||
def flame_graph(file: bytes = File(...)):
|
def flame_graph(file: bytes = File(...), width: int = 1200):
|
||||||
key = str(uuid.uuid4())
|
key = str(uuid.uuid4())
|
||||||
temp = "/dev/shm/fg_%s.bin" % key
|
temp = "/dev/shm/fg_%s.bin" % key
|
||||||
with open(temp, "wb") as f:
|
with open(temp, "wb") as f:
|
||||||
@ -51,7 +51,8 @@ def flame_graph(file: bytes = File(...)):
|
|||||||
)
|
)
|
||||||
|
|
||||||
p3 = Popen(
|
p3 = Popen(
|
||||||
["perl", "flamegraph.pl"],
|
["perl", "flamegraph.pl", "--bgcolors", "#FFFFFF",
|
||||||
|
"--fontsize", "10", "--fonttype", "monospace", "--width", str(width), "--title", " "],
|
||||||
cwd="./FlameGraph",
|
cwd="./FlameGraph",
|
||||||
stdin=PIPE, stdout=PIPE, stderr=PIPE
|
stdin=PIPE, stdout=PIPE, stderr=PIPE
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container>
|
<v-container id="flamegraph-container">
|
||||||
|
|
||||||
<p>Run with <code>perf record -F997 --call-graph dwarf -q <program></code></p>
|
<p>Run with <code>perf record -F997 --call-graph dwarf -q <program></code></p>
|
||||||
|
|
||||||
|
<p>You can also upload the file manually with <code>curl -s -XPOST {{apiUrl}}/flame_graph -F "file=@perf.data" | jq -r .key | xargs printf "{{apiUrl}}/flame_graph/%s\n" $1</code></p>
|
||||||
|
|
||||||
<v-file-input :loading="loading" label="perf.data" id="flamegraph-upload" @change="onUpload()"></v-file-input>
|
<v-file-input :loading="loading" label="perf.data" id="flamegraph-upload" @change="onUpload()"></v-file-input>
|
||||||
|
|
||||||
<object v-if="key" type="image/svg+xml" :data="getGraphUrl()"></object>
|
<object v-if="key" type="image/svg+xml" :data="getGraphUrl()"></object>
|
||||||
@ -25,6 +27,7 @@ export default class FlameGraph extends Vue {
|
|||||||
public tool = toolByName('FlameGraph')
|
public tool = toolByName('FlameGraph')
|
||||||
public key: string | null = null
|
public key: string | null = null
|
||||||
public loading = false
|
public loading = false
|
||||||
|
public apiUrl = API_URL
|
||||||
|
|
||||||
getGraphUrl() {
|
getGraphUrl() {
|
||||||
return `${API_URL}/flame_graph/${this.key}`
|
return `${API_URL}/flame_graph/${this.key}`
|
||||||
@ -39,6 +42,9 @@ export default class FlameGraph extends Vue {
|
|||||||
axios.post('http://localhost:8000/flame_graph', formData, {
|
axios.post('http://localhost:8000/flame_graph', formData, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data'
|
'Content-Type': 'multipart/form-data'
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
width: document.getElementById("flamegraph-container")?.offsetWidth.toString()
|
||||||
}
|
}
|
||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
const result = resp.data as FlameGraphResult
|
const result = resp.data as FlameGraphResult
|
||||||
|
Loading…
x
Reference in New Issue
Block a user