diff options
author | Andreas Herrmann <andreash87@gmx.ch> | 2016-01-11 11:36:50 +0100 |
---|---|---|
committer | Andreas Herrmann <andreash87@gmx.ch> | 2016-01-11 15:37:07 +0100 |
commit | 79e145a970b476eaac79e92e1952232b9892e509 (patch) | |
tree | bebf68ab8a4689ff82f75f38866f0f2475d0b092 /pkgs/tools/graphics/gnuplot | |
parent | 7b0613d51e072708b07de94a574ad7f0a128e450 (diff) | |
download | nixpkgs-79e145a970b476eaac79e92e1952232b9892e509.tar nixpkgs-79e145a970b476eaac79e92e1952232b9892e509.tar.gz nixpkgs-79e145a970b476eaac79e92e1952232b9892e509.tar.bz2 nixpkgs-79e145a970b476eaac79e92e1952232b9892e509.tar.lz nixpkgs-79e145a970b476eaac79e92e1952232b9892e509.tar.xz nixpkgs-79e145a970b476eaac79e92e1952232b9892e509.tar.zst nixpkgs-79e145a970b476eaac79e92e1952232b9892e509.zip |
gnuplot: Improve startup performance
Before executing the gnuplot executable the environment variable `GDFONTPATH` is populated with a list of font directories, which is obtained from `fc-list`. In that process we iterated over each line and called `dirname` on it, which introduces a performance hit for loading and executing the external executable `dirname` every time. The new version avoids the loop. The author of this patch measured a 42 fold performance improvement: old version: $ time ./gnuplot_old/bin/gnuplot -e '' real 0m3.828s user 0m0.392s sys 0m0.465s new version: $ time ./gnuplot_new2/bin/gnuplot -e '' real 0m0.091s user 0m0.112s sys 0m0.014s The correctness of the value of `GDFONTPATH` was confirmed with the following command and comparing its output between versions: $ gnuplot -e 'print system("echo $GDFONTPATH")'
Diffstat (limited to 'pkgs/tools/graphics/gnuplot')
-rw-r--r-- | pkgs/tools/graphics/gnuplot/set-gdfontpath-from-fontconfig.sh | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/pkgs/tools/graphics/gnuplot/set-gdfontpath-from-fontconfig.sh b/pkgs/tools/graphics/gnuplot/set-gdfontpath-from-fontconfig.sh index 4886b4f2b7c..92ad2e97b5b 100644 --- a/pkgs/tools/graphics/gnuplot/set-gdfontpath-from-fontconfig.sh +++ b/pkgs/tools/graphics/gnuplot/set-gdfontpath-from-fontconfig.sh @@ -1,4 +1,4 @@ -p=( $(for n in $(fc-list | sed -r -e 's|^([^:]+):.*$|\1|'); do echo $(dirname "$n"); done | sort | uniq) ) +p=( $(fc-list : file | sed "s@/[^/]*: @@" | sort -u) ) IFS=: export GDFONTPATH="${GDFONTPATH}${GDFONTPATH:+:}${p[*]}" unset IFS p |