-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- use sqlite from python to calculate valid events inside traces - reuse `dftracer_event_count` for sanity checking inside `dftracer_split`
- Loading branch information
Showing
5 changed files
with
118 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash | ||
|
||
# The script will count number of valid events of traces | ||
# This has the following signature. | ||
# | ||
# usage: dftracer_split [-c] [-d input_directory] | ||
# -d input_directory specify input directories. should contain .pfw or .pfw.gz files. | ||
# -f override generated files | ||
# -c disable create index (assuming index exists, if not will throw error) | ||
# -h display help | ||
|
||
LOG_DIR=$PWD | ||
run_create_index=1 | ||
|
||
function usage { | ||
echo "usage: $(basename $0) [-c] [-d input_directory]" | ||
echo " -h display help" | ||
echo " -c disable create index (assuming index exists, if not will throw error)" | ||
echo " -d input_directory specify input directories. should contain .pfw or .pfw.gz files." | ||
exit 1 | ||
} | ||
while getopts ':cd:h' opt; do | ||
case "$opt" in | ||
c) | ||
run_create_index=0 | ||
;; | ||
d) | ||
LOG_DIR="${OPTARG}" | ||
;; | ||
h) | ||
usage | ||
exit 0 | ||
;; | ||
:) | ||
echo -e "option requires an argument.\n" | ||
usage | ||
exit 1 | ||
;; | ||
|
||
?) | ||
echo -e "Invalid command option.\n" | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
shift "$(($OPTIND -1))" | ||
|
||
function get_lines_count { | ||
local dir=$1 | ||
|
||
# if dir empty use current dir | ||
if [ -z "$dir" ]; then | ||
dir=$PWD | ||
fi | ||
|
||
pushd $dir > /dev/null | ||
|
||
lines_count=$(cat <<-EOF | python3 | ||
import zindex_py as zindex | ||
import glob | ||
import sqlite3 | ||
lines_count = 0 | ||
for file in sorted(glob.glob("*.pfw.gz")): | ||
conn = sqlite3.connect(f"{file}.zindex") | ||
res = conn.execute("select count(line) as a from LineOffsets where length > 8;") | ||
lines_count += res.fetchone()[0] | ||
print(lines_count) | ||
EOF) | ||
popd > /dev/null | ||
echo $lines_count | ||
} | ||
if [ "$run_create_index" == "1" ]; then | ||
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" | ||
$SCRIPT_DIR/dftracer_create_index -c -d $LOG_DIR -f >/dev/null | ||
fi | ||
get_lines_count $LOG_DIR |
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