grep-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep branch, master, updated. v3.7-6-g9f296c1


From: Jim Meyering
Subject: Re: grep branch, master, updated. v3.7-6-g9f296c1
Date: Sun, 22 Aug 2021 09:43:45 +0200

> commit 9f296c1238183261afd47e27bf63e505f0b358d5
> Author: Paul Eggert <eggert@cs.ucla.edu>
> Date:   Wed Aug 18 19:03:05 2021 -0700
>
>     tests: port mb-non-UTF8-perf-Fw to strict POSIX
>
>     * tests/mb-non-UTF8-perf-Fw: Prefer ‘sed 10q’ to ‘head -10’,
>     which doesn’t conform to POSIX.
...
> -yes 00 | head -10000000 > in || framework_failure_
> +yes 00 | sed 10000000q > in || framework_failure_

I have a bias against sed.
Let's use head with its POSIX-conforming -n option instead.
This makes it so the command to generate that input file runs in 1/4 the time:

-yes 00 | sed 10000000q > in || framework_failure_
+yes 00 | head -n 10000000 > in || framework_failure_

I've just pushed this:

From: Jim Meyering <meyering@fb.com>
Date: Sun, 22 Aug 2021 09:39:47 +0200
Subject: [PATCH] tests: mb-non-UTF8-perf-Fw: use head rather than sed

* tests/mb-non-UTF8-perf-Fw: Use head -n 10000000 rather than the
work-alike sed command.  This provides a 4x speedup and saves 0.5s.
* tests/null-byte: Likewise.
---
 tests/mb-non-UTF8-perf-Fw | 2 +-
 tests/null-byte           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/mb-non-UTF8-perf-Fw b/tests/mb-non-UTF8-perf-Fw
index 44f3509..cdf7e22 100755
--- a/tests/mb-non-UTF8-perf-Fw
+++ b/tests/mb-non-UTF8-perf-Fw
@@ -23,7 +23,7 @@ fail=0
 require_timeout_
 require_JP_EUC_locale_

-yes 00 | sed 10000000q > in || framework_failure_
+yes 00 | head -n 10000000 > in || framework_failure_

 # Since we're using an absolute timeout below and want to avoid any initial
 # disk read performance penalty, run first with a large timeout and no error
diff --git a/tests/null-byte b/tests/null-byte
index 9402c2b..d86c249 100755
--- a/tests/null-byte
+++ b/tests/null-byte
@@ -51,7 +51,7 @@ for left in '' a '#' '\0'; do
   done
 done

-(echo xxx && yes yyy | sed 100000q && printf 'z\n\0') >in || framework_failure_
+(echo xxx && yes yyy | head -n 100000 && printf 'z\n\0') >in ||
framework_failure_
 echo xxx >exp || framework_failure_
 grep xxx in >out || fail=1
 compare exp out || fail=1
-- 
2.33.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]