FS/XFS testing framework
 help / color / mirror / Atom feed
* [PATCH v2 0/3] use shuf to choose a random file
@ 2023-08-21  6:37 Naohiro Aota
  2023-08-21  6:37 ` [PATCH v2 1/3] common/rc: introduce _random_file() helper Naohiro Aota
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Naohiro Aota @ 2023-08-21  6:37 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Naohiro Aota

Currently, we use "ls ... | sort -R | head -n1" (or tail) to choose a
random file in a directory.It sorts the files with "ls", sort it randomly
and pick the first line, which wastes the "ls" sort.

Also, using "sort -R | head -n1" is inefficient. Furthermore, even without
"head" or "tail", "shuf" is faster than "sort -R".

This series introduces a new helper _random_file() to choose a file in a
directory randomly. Also, replace "sort -R" with _random_file() or "shuf".

Naohiro Aota (3):
  common/rc: introduce _random_file() helper
  fstests/btrfs: use _random_file() helper
  btrfs/004: use shuf to shuffle the file lines

 common/rc       |  7 +++++++
 tests/btrfs/004 |  2 +-
 tests/btrfs/179 |  4 ++--
 tests/btrfs/192 | 14 ++++----------
 4 files changed, 14 insertions(+), 13 deletions(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-21  6:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-21  6:37 [PATCH v2 0/3] use shuf to choose a random file Naohiro Aota
2023-08-21  6:37 ` [PATCH v2 1/3] common/rc: introduce _random_file() helper Naohiro Aota
2023-08-21  6:37 ` [PATCH v2 2/3] fstests/btrfs: use " Naohiro Aota
2023-08-21  6:37 ` [PATCH v2 3/3] btrfs/004: use shuf to shuffle the file lines Naohiro Aota
2023-08-21  6:52 ` [PATCH v2 0/3] use shuf to choose a random file Naohiro Aota

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox