summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/hash-collision-perf6
-rw-r--r--tests/init.cfg14
-rwxr-xr-xtests/long-pattern-perf3
3 files changed, 17 insertions, 6 deletions
diff --git a/tests/hash-collision-perf b/tests/hash-collision-perf
index 52266b63..898b496d 100755
--- a/tests/hash-collision-perf
+++ b/tests/hash-collision-perf
@@ -28,8 +28,7 @@ fail=0
# for digits, which never exhibited a problem with hash collisions.
n_pat=40000
while :; do
- script="BEGIN { for (i = 1; i <= $n_pat; i++) print i }"
- ${AWK-awk} "$script" < /dev/null > in || framework_failure_
+ seq $n_pat > in || framework_failure_
small_ms=$(LC_ALL=C user_time_ 1 grep --file=in empty) || fail=1
test $small_ms -ge 200 && break
n_pat=$(expr $n_pat '*' 2)
@@ -37,8 +36,7 @@ done
# Now, search for those same digits mapped to A-J.
# With the PJW-based hash function, this became O(N^2).
-script="BEGIN { for (i = 1; i <= $n_pat; i++) print i }"
-${AWK-awk} "$script" </dev/null | tr 0-9 A-J > in || framework_failure_
+seq $n_pat | tr 0-9 A-J > in || framework_failure_
large_ms=$(LC_ALL=C user_time_ 1 grep --file=in empty) || fail=1
# Deliberately recording in an unused variable so it
diff --git a/tests/init.cfg b/tests/init.cfg
index 4abe55ae..72cab203 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -204,3 +204,17 @@ user_time_()
# yes is not portable, fake it with $AWK
yes() { line=${*-y} ${AWK-awk} 'BEGIN{for (;;) print ENVIRON["line"]}'; }
+
+# Some systems lack seq.
+# A limited replacement for seq: handle 1 or 2 args; increment must be 1
+if ! type seq > /dev/null 2>&1; then
+ seq()
+ {
+ case $# in
+ 1) start=1 final=$1;;
+ 2) start=$1 final=$2;;
+ *) echo you lose 1>&2; exit 1;;
+ esac
+ awk 'BEGIN{for(i='$start';i<='$final';i++) print i}' < /dev/null
+ }
+fi
diff --git a/tests/long-pattern-perf b/tests/long-pattern-perf
index a4cb089f..8151c1ac 100755
--- a/tests/long-pattern-perf
+++ b/tests/long-pattern-perf
@@ -27,8 +27,7 @@ expensive_
echo x > in || framework_failure_
# Note that we want 10x the byte count (not line count) in the larger file.
-script='BEGIN { for (i=10000; i<=50000; i++) printf "%d", i }'
-${AWK-awk} "$script" < /dev/null > r || framework_failure_
+seq 10000 50000 | tr -d '\012' > r || framework_failure_
cat r r r r r r r r r r > re-10x || framework_failure_
mv r re || framework_failure_