Skip to content

Instantly share code, notes, and snippets.

@alexandrumc
Last active April 18, 2020 07:02
Show Gist options
  • Save alexandrumc/07c1b569e7e38212203457bfadb723fb to your computer and use it in GitHub Desktop.
Save alexandrumc/07c1b569e7e38212203457bfadb723fb to your computer and use it in GitHub Desktop.
Script for measuring compile-time variations of DMD
#!/bin/bash
touchfiles="
touch $HOME/.dub/packages/phobos-master/phobos/std/file.d
touch $HOME/.dub/packages/mir-optim-1.5.1/mir-optim/source/mir/optim/least_squares.d
touch $HOME/.dub/packages/mir-cpuid-1.2.2/mir-cpuid/source/cpuid/x86_any.d
touch $HOME/.dub/packages/mir-core-1.0.3/mir-core/source/mir/conv.d
touch $HOME/.dub/packages/mir-3.2.0/mir/source/mir/model/lda/hoffman.d
touch $HOME/.dub/packages/imageformats-7.0.2/imageformats/imageformats/jpeg.d
touch $HOME/.dub/packages/lubeck-1.1.7/lubeck/source/lubeck.d
touch $HOME/.dub/packages/excel-d-0.5.7/excel-d/source/xlld/any.d
touch $HOME/.dub/packages/requests-1.0.14/requests/source/requests/http.d
touch $HOME/.dub/packages/scid-0.3.1/scid/source/scid/calculus.d
touch $HOME/.dub/packages/undead-1.1.1/undead/src/undead/cstream.d
touch $HOME/.dub/packages/containers-0.2.2/containers/src/containers/hashset.d
touch $HOME/.dub/packages/intel-intrinsics-1.2.2/intel-intrinsics/source/inteli/package.d
touch $HOME/.dub/packages/automem-0.6.1/automem/source/automem/allocator.d
touch $HOME/.dub/packages/dfmt-0.11.0/dfmt/src/dfmt/main.d
touch $HOME/.dub/packages/optional-1.0.0/optional/source/optional/oc.d
touch $HOME/.dub/packages/libdparse-0.8.8/libdparse/src/dparse/lexer.d
touch $HOME/.dub/packages/mir-random-2.2.10/mir-random/source/mir/random/algorithm.d
touch $HOME/.dub/packages/dyaml-0.8.0/dyaml/source/dyaml/dumper.d
touch $HOME/.dub/packages/mir-algorithm-3.7.17/mir-algorithm/source/mir/parse.d
touch $HOME/.dub/packages/dxml-0.4.1/dxml/source/dxml/internal.d
touch $HOME/.dub/packages/ae-0.0.2518/ae/sys/database.d
touch $HOME/.dub/packages/dcd-0.12.0/dcd/src/dcd/client/client.d
touch $HOME/.dub/packages/dagon-0.10.2/dagon/src/dagon/core/event.d
touch $HOME/.dub/packages/poodinis-8.0.3/poodinis/source/poodinis/factory.d
touch $HOME/.dub/packages/diet-ng-1.6.1/diet-ng/source/diet/input.d
touch $HOME/.dub/packages/dwt-1.0.3_swt-3.4.1/dwt/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/std.d
touch $HOME/.dub/packages/tsv-utils-1.5.0/tsv-utils/tsv-join/src/tsv_utils/tsv-join.d
touch $HOME/.dub/packages/ggplotd-1.2.1/ggplotd/source/ggplotd/ggplotd.d
touch $HOME/.dub/packages/ddox-0.16.13/ddox/source/ddox/entities.d
touch $HOME/.dub/packages/dproto-2.1.5/dproto/dprotoc/src/app.d
touch $HOME/.dub/packages/vectorflow-1.0.2/vectorflow/src/vectorflow/monitor.d
touch $HOME/.dub/packages/dunit-1.0.16/dunit/source/dunit/reflection.d
touch $HOME/.dub/packages/sumtype-0.9.4/sumtype/src/sumtype.d
touch $HOME/.dub/packages/mustache-d-0.1.4/mustache-d/src/mustache.d
touch $HOME/.dub/packages/std_data_json-0.18.4/std_data_json/source/stdx/data/json/generator.d
touch $HOME/.dub/packages/taggedalgebraic-0.11.9/taggedalgebraic/source/taggedalgebraic/taggedalgebraic.d
"
declare -a buildpaths=(
"$HOME/.dub/packages/phobos-master/phobos/.dub/build/*"
"$HOME/.dub/packages/ddox-0.16.13/ddox/.dub/build/*"
"$HOME/.dub/packages/tsv-utils-1.5.0/tsv-utils/.dub/build/*"
"$HOME/.dub/packages/dwt-1.0.3_swt-3.4.1/dwt/.dub/build/*"
"$HOME/.dub/packages/diet-ng-1.6.1/diet-ng/.dub/build/*"
"$HOME/.dub/packages/poodinis-8.0.3/poodinis/.dub/build/*"
"$HOME/.dub/packages/dagon-0.10.2/dagon/.dub/build/*"
"$HOME/.dub/packages/dcd-0.12.0/dcd/.dub/build/*"
"$HOME/.dub/packages/dxml-0.4.1/dxml/.dub/build/*"
"$HOME/.dub/packages/mir-algorithm-3.7.17/mir-algorithm/.dub/build/*"
"$HOME/.dub/packages/dyaml-0.8.0/dyaml/.dub/build/*"
"$HOME/.dub/packages/mir-random-2.2.10/mir-random/.dub/build/*"
"$HOME/.dub/packages/libdparse-0.8.8/libdparse/.dub/build/*"
"$HOME/.dub/packages/optional-1.0.0/optional/.dub/build/*"
"$HOME/.dub/packages/dfmt-0.11.0/dfmt/.dub/build/*"
"$HOME/.dub/packages/automem-0.6.1/automem/.dub/build/*"
"$HOME/.dub/packages/intel-intrinsics-1.2.2/intel-intrinsics/.dub/build/*"
"$HOME/.dub/packages/containers-0.2.2/containers/.dub/build/*"
"$HOME/.dub/packages/undead-1.1.1/undead/.dub/build/*"
"$HOME/.dub/packages/scid-0.3.1/scid/.dub/build/*"
"$HOME/.dub/packages/requests-1.0.14/requests/.dub/build/*"
"$HOME/.dub/packages/lubeck-1.1.7/lubeck/.dub/build/*"
"$HOME/.dub/packages/imageformats-7.0.2/imageformats/.dub/build/*"
"$HOME/.dub/packages/mir-core-1.0.3/mir-core/.dub/build/*"
"$HOME/.dub/packages/mir-cpuid-1.2.2/mir-cpuid/.dub/build/*"
"$HOME/.dub/packages/mir-optim-1.5.1/mir-optim/.dub/build/*"
"$HOME/.dub/packages/dproto-2.1.5/dproto/.dub/build/*"
"$HOME/.dub/packages/vectorflow-1.0.2/vectorflow/.dub/build/*"
"$HOME/.dub/packages/dunit-1.0.16/dunit/.dub/build/*"
"$HOME/.dub/packages/sumtype-0.9.4/sumtype/.dub/build/*"
"$HOME/.dub/packages/mustache-d-0.1.4/mustache-d/.dub/build/*"
"$HOME/.dub/packages/std_data_json-0.18.4/std_data_json/.dub/build/*"
"$HOME/.dub/packages/taggedalgebraic-0.11.9/taggedalgebraic/.dub/build/*"
)
#for i in "${buildpaths[@]}"
#do
#echo "$i"
#done
projects=(
"dlang/phobos" # 4m50s
"rejectedsoftware/ddox" # 2m42s
"eBay/tsv-utils" # 1m41s
"d-widget-toolkit/dwt" # 1m16s
"rejectedsoftware/diet-ng" # 56s
"mbierlee/poodinis" # 40s
"gecko0307/dagon" # 25s
"dlang-community/dcd" # 23s
"jmdavis/dxml" # 22s
"libmir/mir-algorithm" # 17s
"dlang-community/dyaml" # 15s
"libmir/mir-random" # 13s
"dlang-community/libdparse" # 13s
"aliak00/optional" # 12s
"dlang-community/dfmt" # 11s
"atilaneves/automem"
"AuburnSounds/intel-intrinsics"
"dlang-community/containers"
"dlang/undead"
"DlangScience/scid"
"ikod/requests"
"kaleidicassociates/lubeck"
"lgvz/imageformats"
"libmir/mir-core"
"libmir/mir-cpuid"
"libmir/mir-optim"
"msoucy/dproto"
"Netflix/vectorflow"
"nomad-software/dunit"
"pbackus/sumtype"
"repeatedly/mustache-d"
"s-ludwig/std_data_json"
"s-ludwig/taggedalgebraic"
)
DMD="/usr/bin/dmd"
CUSTOMDMD="/home/alexandrucm/dlang/dmd/generated/linux/release/64/dmd"
$touchfiles
counter=0
for project_name in "${projects[@]}" ; do
project="$(echo "$project_name" | sed "s/\([^+]*\)+.*/\1/")"
project="$(basename "$project")"
path=${buildpaths[$counter]}
echo -e "\n["$project"]\n" >> results.txt
# debug build
echo -e "\t[Debug build]\n" >> results.txt
echo -e "\t\tDMD:" >> results.txt
rm -rf $path
(time dub build --nodeps --skip-registry=all --build=debug --vquiet --compiler=$DMD $project) 2>> results.txt > /dev/null
value=$(find $path -type f -iname "*.[ao]" | xargs du -h | cut -f1)
echo -e "\nBinary size: $value \n" >> results.txt
$touchfiles
echo -e "\n\t\tCUSTOMDMD:" >> results.txt
rm -rf $path
(time dub build --nodeps --skip-registry=all --build=debug --vquiet --compiler=$CUSTOMDMD $project) 2>> results.txt > /dev/null
value=$(find $path -type f -iname "*.[ao]" | xargs du -h | cut -f1)
echo -e "\nBinary size: $value \n" >> results.txt
$touchfiles
# release build
echo -e "\n\t[Release build]\n" >> results.txt
if [ "$project" = "dwt" ]; then
echo -e "$project fails on release\n" >> results.txt
else
echo -e "\t\tDMD:" >> results.txt
rm -rf $path
(time dub build --nodeps --skip-registry=all --build=release --vquiet --compiler=$DMD $project) 2>> results.txt > /dev/null
value=$(find $path -type f -iname "*.[ao]" | xargs du -h | cut -f1)
echo -e "\nBinary size: $value \n" >> results.txt
$touchfiles
echo -e "\n\t\tCUSTOMDMD:" >> results.txt
rm -rf $path
(time dub build --nodeps --skip-registry=all --build=release --vquiet --compiler=$CUSTOMDMD $project) 2>> results.txt > /dev/null
value=$(find $path -type f -iname "*.[ao]" | xargs du -h | cut -f1)
echo -e "\nBinary size: $value \n" >> results.txt
fi
$touchfiles
# unittest build
echo -e "\n\t[Unittest build]\n" >> results.txt
if [ "$project" = "phobos" ] || [ "$project" = "automem" ] ||
[ "$project" = "containers" ] || [ "$project" = "lubeck" ] ||
[ "$project" = "mir-optim" ]; then
echo -e "$project fails on unittest\n" >> results.txt
else
echo -e "\t\tDMD:" >> results.txt
rm -rf $path
(time dub build --nodeps --skip-registry=all --build=unittest --vquiet --compiler=$DMD $project) 2>> results.txt > /dev/null
value=$(find $path -type f -iname "*.[ao]" | xargs du -h | cut -f1)
echo -e "\nBinary size: $value \n" >> results.txt
$touchfiles
echo -e "\n\t\tCUSTOMDMD:" >> results.txt
rm -rf $path
(time dub build --nodeps --skip-registry=all --build=unittest --vquiet --compiler=$CUSTOMDMD $project) 2>> results.txt > /dev/null
value=$(find $path -type f -iname "*.[ao]" | xargs du -h | cut -f1)
echo -e "\nBinary size: $value \n" >> results.txt
$touchfiles
echo -e "\n" >> results.txt
fi
counter=$((counter+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment