Created
June 8, 2020 21:58
-
-
Save rr-codes/88c2072f01c7886d355034ff3fb0c203 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/bin/bash | |
| # Given a folder of source *.cpp files, compiles each file and profiles heap and stack usage with massif. | |
| # Results are added to a "massif" directory in the pwd | |
| # a) create two subdirectories titled 'generated' and 'massif' in the cwd | |
| # b) iterate over each file inside the directory specified by the first argument | |
| # c) for each file, run `g++` on it and store the executable in /generated | |
| # d) for each file in /generated, run `massif` on it and store the output in \massif | |
| # e) done | |
| generated="${PWD}/generated" | |
| massif="${PWD}/massif" | |
| rm -rf ${generated}; mkdir -v ${generated} | |
| rm -rf ${massif}; mkdir -v ${massif} | |
| echo "" | |
| for file in $1/*.cpp | |
| do | |
| echo "Building ${file}..." | |
| name_ext=${file##*/} | |
| name=${name_ext%.*} | |
| executable="./${generated}/${name}" | |
| g++ ${file} -std=c++17 -isystem ~/etl-18.1.3/include -o ${executable} | |
| chmod u+x ${executable} | |
| done | |
| echo "" | |
| for file in ${generated}/* | |
| do | |
| echo "Running massif on ${file}..." | |
| name_ext=${file##*/} | |
| name=${name_ext%.*} | |
| valgrind --tool=massif --massif-out-file="${massif}/${name}.txt" --time-unit=B --stacks=yes ${file} | |
| done | |
| echo "" | |
| echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment