]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
Try to become able to use a time builtin again. Fixes timing on msys.
authorRudolf Polzer <divverent@xonotic.org>
Sat, 18 Jan 2014 13:52:26 +0000 (14:52 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 18 Jan 2014 13:52:26 +0000 (14:52 +0100)
misc/tools/all/config.subr
misc/tools/all/git.subr
misc/tools/all/xonotic.subr

index 1c560fa97c06777259ba058819ddef7023f9630a..38a90bde0b7b0d532bd94e39f476712f02306f50 100644 (file)
@@ -35,10 +35,18 @@ allmirrors()
        "$@" ssh  push ssh://xonotic@push.git.xonotic.org/ ''
 }
 
-time="time -p"
-if { $time sh -c 'true'; } 2>&1 >/dev/null | grep '^user ' >/dev/null; then
+have_time=true
+measure_time()
+{
+       if $have_time; then
+               time -p "$@"
+       else
+               "$@"
+       fi
+}
+if { measure_time sh -c 'true'; } 2>&1 >/dev/null | grep '^user ' >/dev/null; then
        msg "Timing via the time utility works."
 else
-       time=
+       have_time=false
        msg "Timing not supported."
 fi
index c29685dc6622334f04f6ab708d75abfd05a0b5d9..5c8d53dc18094585f3304c830d4e41f67e7a813e 100644 (file)
@@ -56,7 +56,7 @@ mirrorspeed()
        # first result is to be ignored, but we use it to check status
        git ls-remote "$1" refs/heads/master >/dev/null 2>&1 || return 1
        # if we can't time, we only check availability
-       if [ -z "$time" ]; then
+       if ! $have_time; then
                echo 0
                return
        fi
@@ -64,7 +64,7 @@ mirrorspeed()
        (
                set +x
                export REPO=$1 # so that the sh -c subshell can use it
-               { $time sh -c 'git ls-remote "$REPO" refs/heads/master >/dev/null 2>&1'; } 2>&1 >/dev/null | head -n 1 | cut -d ' ' -f 2 | tr -d . | sed 's,^0*,,' | grep . || echo 0
+               { measure_time sh -c 'git ls-remote "$REPO" refs/heads/master >/dev/null 2>&1'; } 2>&1 >/dev/null | head -n 1 | cut -d ' ' -f 2 | tr -d . | sed 's,^0*,,' | grep . || echo 0
                        # unit: clock ticks (depends on what "time" returns
        )
 }
index 2d7025f9a9ff68e89b7108b01e6f62140aeffcfc..96a82a3007cd8406e021940a4bb0fb0b5114b919 100644 (file)
@@ -17,7 +17,7 @@ case "$cmd" in
                        if [ ! -f "$mapfile" ] ; then
                                msg "ERROR, $mapfile not found!"
                        else
-                               verbose $time misc/tools/xonotic-map-compiler-optionsfile "$mapfile"
+                               verbose measure_time misc/tools/xonotic-map-compiler-optionsfile "$mapfile"
                        fi
                done
                ;;
@@ -336,7 +336,7 @@ case "$cmd" in
                        set -- rlwrap -A -g '^quit' -q "\"" -s 10000 -S ']' -w 100 "$@"
                fi
                rm -f xonotic.core
-               verbose $time "$@" || true
+               verbose measure_time "$@" || true
                if [ -f xonotic.core ]; then
                        if yesno "The program has CRASHED. Do you want to examine the core dump?"; then
                                gdb "$binary" xonotic.core