forked from opentx/opentx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lua memory (de)allocation tracer: (opentx#5191)
* Lua memory (de)allocation tracer: Usage: * turn on: `cmake -DLUA=YES -DLUA_ALLOCATOR_TRACER=YES -DDEBUG=YES -DNANO=NO` * get debug output and make plot data: `./simu 2>&1 | grep "^LT" | ../radio/util/lua_trace2plot.py > data.plot` * plot: `gnuplot -e 'set xtics rotate; plot "data.plot" using 2:xtic(1) ; pause mouse close'` * Changes based on Bertrand comments
- Loading branch information
1 parent
c30ff28
commit f0f3e35
Showing
6 changed files
with
161 additions
and
8 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
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
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,55 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
This script parses debug log events related to Lua memory (de)allocations ( lines | ||
starting wiht "LT: ") and produces a data for gnuplot program | ||
Usage: | ||
./simu 2>&1 | grep "^LT" | ../radio/util/lua_trace2plot.py > data.plot | ||
gnuplot -e 'set xtics rotate; plot "data.plot" using 2:xtic(1) ; pause mouse close' | ||
""" | ||
|
||
from __future__ import print_function | ||
|
||
import sys | ||
|
||
|
||
if len(sys.argv) > 1: | ||
inputFile = sys.argv[1] | ||
inp = open(inputFile, "r") | ||
else: | ||
inp = sys.stdin | ||
|
||
|
||
x = 0 | ||
memUsed = 0 | ||
while True: | ||
skip = True | ||
line = inp.readline() | ||
if len(line) == 0: | ||
break | ||
line = line.strip('\r\n') | ||
if len(line) == 0: | ||
skip = True | ||
if line.startswith("LT:"): | ||
skip = False | ||
|
||
if not skip: | ||
parts = line.split() | ||
if len(parts) >= 3: | ||
data = parts[1].strip("[").strip("]").split(",") | ||
alloc = int(data[0]) | ||
free = int(data[1]) | ||
line = parts[2] | ||
if alloc > 0: | ||
memUsed += alloc | ||
print("'%s'\t%d" % (line, memUsed)) | ||
x += 1 | ||
if free < 0: | ||
memUsed += free | ||
print("'%s'\t%d" % (line, memUsed)) | ||
x += 1 | ||
|
||
inp.close() |