[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Optimize compile script on MSYS.
From: |
Peter Rosin |
Subject: |
[PATCH] Optimize compile script on MSYS. |
Date: |
Mon, 16 Aug 2010 13:59:13 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 |
Hi!
As suggested by Ralf, there is room for improvement in the compile
script. There is no need to convert filenames when MSYS is going to
do it anyway, especially when the conversion costs a bunch of forks.
I have tested this patch with this:
cat > filenames << 'EOF'
#! /bin/sh
foo=0
while test $foo -lt $1
do
foo=$(($foo + 1))
args="$args $2$foo$3"
done
echo "$args"
EOF
chmod 755 filenames
time for file in `./filenames 20 / .cc`; do ./compile cl $file; done
real 0m9.781s
user 0m5.532s
sys 0m4.609s
time for file in `./filenames 20 / .cpp`; do ./compile cl $file; done
real 0m5.547s
user 0m1.737s
sys 0m1.890s
time ./compile cl `./filenames 20 / .cc`
real 0m5.218s
user 0m3.871s
sys 0m3.158s
time ./compile cl `./filenames 20 / .cpp`
real 0m0.734s
user 0m0.106s
sys 0m0.154s
The C++ files don't exist, so this includes the time for cl determining
that and outputing an error message (which I snipped).
For reference, here's a run from before the patch:
time for file in `./filenames 20 / .cc`; do ./oldcompile cl $file; done
real 0m9.875s
user 0m5.718s
sys 0m4.483s
time for file in `./filenames 20 / .cpp`; do ./oldcompile cl $file; done
real 0m9.906s
user 0m5.498s
sys 0m4.822s
time ./oldcompile cl `./filenames 20 / .cc`
real 0m5.187s
user 0m4.026s
sys 0m2.912s
time ./oldcompile cl `./filenames 20 / .cpp`
real 0m5.156s
user 0m4.044s
sys 0m2.898s
To conclude, this shaves off 4-5 seconds when compiling 20 files with
absolute file names on MSYS. The cost when the new code isn't needed
seems negligible in comparison. I get the same 4-5 seconds improvement
when I run with this fake cl script:
cat > cl << 'EOF'
#! /bin/sh
echo "$@"
EOF
That said, don't expect too much from this as using absolute file
names is not really the common case...
Cheers,
Peter
0001-Optimize-compile-script-on-MSYS.patch.txt
Description: Text document
- [PATCH] Optimize compile script on MSYS.,
Peter Rosin <=