[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Why `$(<` is slow?
From: |
Vishal Verma |
Subject: |
Re: [Help-bash] Why `$(<` is slow? |
Date: |
Thu, 29 Aug 2019 20:02:25 -0600 |
On Thu, 2019-08-29 at 20:39 -0500, Peng Yu wrote:
> I got the following runtime. `read` is the fastest (the last time statement).
>
> But `$(<` is doing the same thing (the 4th time statement), shouldn't
> it be as quick as read?
[..]
> time for((i=0;i<1000;++i)); do ( cat "$tmpfile" ) done
> time for((i=0;i<1000;++i)); do x=$(cat "$tmpfile"); done
> time for((i=0;i<1000;++i)); do x=$(< "$tmpfile"); done
The above three spawn subshells
> time for((i=0;i<1000;++i)); do read -d '' -r x < "$tmpfile"; done
where as this one doesn't.