diff options
author | Naohiro Aota <naohiro.aota@wdc.com> | 2023-08-21 16:12:13 +0900 |
---|---|---|
committer | Zorro Lang <zlang@kernel.org> | 2023-08-25 22:20:51 +0800 |
commit | a0c6958c0e36a1481cd751c828ab1aa15de6b934 (patch) | |
tree | 1bf73a2a3a675a5387697bceff10cc9a2583985d | |
parent | 4dd2822ae01a6521226f0fc761007cbc8536b12c (diff) | |
download | xfstests-dev-a0c6958c0e36a1481cd751c828ab1aa15de6b934.tar.gz |
btrfs/004: use shuf to shuffle the file lines
The "sort -R" is slower than "shuf" even with the full output because
"sort -R" actually sort them to group the identical keys.
$ time bash -c "seq 1000000 | shuf >/dev/null"
bash -c "seq 1000000 | shuf >/dev/null" 0.18s user 0.03s system 104% cpu 0.196 total
$ time bash -c "seq 1000000 | sort -R >/dev/null"
bash -c "seq 1000000 | sort -R >/dev/null" 19.61s user 0.03s system 99% cpu 19.739 total
Since the "find"'s outputs never be identical, we can just use "shuf" to
optimize the selection.
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
-rwxr-xr-x | tests/btrfs/004 | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/btrfs/004 b/tests/btrfs/004 index ea40dbf628..78df6a3af6 100755 --- a/tests/btrfs/004 +++ b/tests/btrfs/004 @@ -201,7 +201,7 @@ workout() cnt=0 errcnt=0 dir="$SCRATCH_MNT/$snap_name/" - for file in `find $dir -name f\* -size +0 | sort -R`; do + for file in `find $dir -name f\* -size +0 | shuf`; do extents=`_check_file_extents $file` ret=$? if [ $ret -ne 0 ]; then |