common/config: implement set_prog_path() using 'type -P'
authorEric Biggers <ebiggers@google.com>
Sat, 6 May 2017 00:19:33 +0000 (17:19 -0700)
committerEryu Guan <eguan@redhat.com>
Mon, 8 May 2017 07:33:16 +0000 (15:33 +0800)
commit904a46958ca0352d6370572723f20a13b5ecf6f5
treed16c71cd194ed25983df0ed0f461c4b07f18bf89
parent7b1ae2457c81a214ca9f68be70e539fbad6279a5
common/config: implement set_prog_path() using 'type -P'

Bash's 'type -P' builtin is equivalent to 'which', but it's more
efficient because it doesn't involve executing an external binary.
Because set_prog_path() is executed 60+ times in common/config,
which is sourced by common/rc, which in turn is sourced by every
test, switching to 'type -P' actually can make a noticeable
performance improvement for short-running or skipped tests.  For
example:

Before:
    # time ./check generic/002
    ...
    Passed all 1 tests

    real    0m1.365s
    user    0m0.746s
    sys     0m0.644s

After:
    # time ./check generic/002
    ...
    Passed all 1 tests

    real    0m1.026s
    user    0m0.511s
    sys     0m0.470s

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/config