mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 04:01:36 +01:00
ported bst-vs-heap
This commit is contained in:
@@ -7692,7 +7692,7 @@ Usage:
|
|||||||
....
|
....
|
||||||
printf '/bst_vs_heap.out' > data/readfile
|
printf '/bst_vs_heap.out' > data/readfile
|
||||||
./run -aA -g -F '/gem5.sh'
|
./run -aA -g -F '/gem5.sh'
|
||||||
./bst-vs-heap > bst_vs_heap.dat
|
./bst-vs-heap -aA -g > bst_vs_heap.dat
|
||||||
....
|
....
|
||||||
|
|
||||||
and then feed `bst_vs_heap.dat` into: https://github.com/cirosantilli/cpp-cheat/blob/9d0f77792fc8e55b20b6ee32018761ef3c5a3f2f/cpp/interactive/bst_vs_heap.gnuplot
|
and then feed `bst_vs_heap.dat` into: https://github.com/cirosantilli/cpp-cheat/blob/9d0f77792fc8e55b20b6ee32018761ef3c5a3f2f/cpp/interactive/bst_vs_heap.gnuplot
|
||||||
|
|||||||
28
bst-vs-heap
28
bst-vs-heap
@@ -1,11 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env python3
|
||||||
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
import common
|
||||||
while getopts "${common_getopts_flags}" OPT; do
|
parser = common.get_argparse(
|
||||||
case "$OPT" in
|
argparse_args={'description':'Convert a BST vs heap stat file into a gnuplot input'}
|
||||||
?)
|
)
|
||||||
common_getopts_case "$OPT"
|
args = common.setup(parser)
|
||||||
;;
|
stats = common.get_stats()
|
||||||
esac
|
it = iter(stats)
|
||||||
done
|
i = 1
|
||||||
shift "$(($OPTIND - 1))"
|
for stat in it:
|
||||||
"${common_root_dir}/gem5-stat" -a "$common_arch" | awk 'NR % 2 { printf "%d %s ", NR/2, $0; next; } 1'
|
try:
|
||||||
|
next_stat = next(it)
|
||||||
|
except StopIteration:
|
||||||
|
# Automatic dumpstats at end may lead to odd number of stats.
|
||||||
|
break
|
||||||
|
print('{} {} {}'.format(i, stat, next_stat))
|
||||||
|
i += 1
|
||||||
|
|||||||
23
common.py
23
common.py
@@ -135,10 +135,27 @@ around when you checkout between branches.
|
|||||||
parser.set_defaults(**defaults)
|
parser.set_defaults(**defaults)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
def get_stats(stat_re=None, stats_file=None):
|
||||||
|
global this
|
||||||
|
if stat_re is None:
|
||||||
|
stat_re = '^system.cpu[0-9]*.numCycles$'
|
||||||
|
if stats_file is None:
|
||||||
|
stats_file = this.stats_file
|
||||||
|
stat_re = re.compile(stat_re)
|
||||||
|
ret = []
|
||||||
|
with open(stats_file, 'r') as statfile:
|
||||||
|
for line in statfile:
|
||||||
|
if line[0] != '-':
|
||||||
|
cols = line.split()
|
||||||
|
if len(cols) > 1 and stat_re.search(cols[0]):
|
||||||
|
ret.append(cols[1])
|
||||||
|
return ret
|
||||||
|
|
||||||
def print_cmd(cmd, cmd_file=None, extra_env=None):
|
def print_cmd(cmd, cmd_file=None, extra_env=None):
|
||||||
if extra_env is None:
|
"""
|
||||||
extra_env = {}
|
Format a command given as a list of strings so that it can
|
||||||
newline_separator = ' \\\n'
|
be viewed nicely and executed by bash directly.
|
||||||
|
"""
|
||||||
out = []
|
out = []
|
||||||
for key in extra_env:
|
for key in extra_env:
|
||||||
out.extend(['{}={}'.format(shlex.quote(key), shlex.quote(extra_env[key])), newline_separator])
|
out.extend(['{}={}'.format(shlex.quote(key), shlex.quote(extra_env[key])), newline_separator])
|
||||||
|
|||||||
18
gem5-stat
18
gem5-stat
@@ -1,20 +1,14 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import re
|
|
||||||
import common
|
import common
|
||||||
parser = common.get_argparse(
|
parser = common.get_argparse(
|
||||||
argparse_args={'description':'Get the value of a gem5 stat from the stats.txt file.'}
|
argparse_args={'description':'Get the value of a gem5 stat from the stats.txt file.'}
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'stat',
|
'stat',
|
||||||
default='^system.cpu[0-9]*.numCycles$',
|
default=None,
|
||||||
help='Python regexp matching the full stat name of interest',
|
help='Python regexp matching the full stat name of interest',
|
||||||
nargs='?',
|
nargs='?',
|
||||||
)
|
)
|
||||||
args = common.setup(parser)
|
args = common.setup(parser)
|
||||||
stat_re = re.compile(args.stat)
|
stats = common.get_stats(args.stat)
|
||||||
with open(common.stats_file, 'r') as statfile:
|
print('\n'.join(stats))
|
||||||
for line in statfile:
|
|
||||||
if line[0] != '-':
|
|
||||||
cols = line.split()
|
|
||||||
if len(cols) > 1 and stat_re.search(cols[0]):
|
|
||||||
print(cols[1])
|
|
||||||
|
|||||||
Reference in New Issue
Block a user