SHA256
1
0
forked from pool/grep
grep/mb-non-UTF8-performance.patch
2014-03-26 18:41:35 +00:00

69 lines
2.0 KiB
Diff

Index: grep-2.18/tests/init.cfg
===================================================================
--- grep-2.18.orig/tests/init.cfg
+++ grep-2.18/tests/init.cfg
@@ -103,6 +103,21 @@ require_unibyte_locale()
skip_ 'no unibyte locale found'
}
+# Define hi_res_time_ to a function that prints the current time
+# as a floating point number with greater than 1-second resolution.
+# Otherwise, skip the requiring test.
+require_hi_res_time_()
+{
+ local cmd
+ for cmd in 'date +%s.%N' \
+ 'perl -le "use Time::HiRes qw(time); print scalar time()"'; do
+ case $($cmd) in
+ *.[0-9]*) eval 'hi_res_time_() { '"$cmd"'; }'; break;;
+ esac
+ done
+ type hi_res_time_ || skip_ no high-resolution timer support
+}
+
require_JP_EUC_locale_()
{
local locale=ja_JP.eucJP
Index: grep-2.18/tests/mb-non-UTF8-performance
===================================================================
--- grep-2.18.orig/tests/mb-non-UTF8-performance
+++ grep-2.18/tests/mb-non-UTF8-performance
@@ -1,5 +1,7 @@
#!/bin/sh
# grep-2.17 would take nearly 200x longer to run the command below.
+# The 200x is on an Intel i7-based system.
+# On an AMD FX-4100, it would take up to 2500x longer.
# Copyright 2014 Free Software Foundation, Inc.
@@ -18,15 +20,26 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_timeout_
+require_hi_res_time_
fail=0
-require_JP_EUC_locale_
-
yes $(printf '%078d' 0) | head -50000 > in || framework_failure_
+start=$(hi_res_time_)
+LC_ALL=C grep -i foobar in; st=$?
+stop=$(hi_res_time_)
+
+# Use a multiple of the LC_ALL=C duration as the timeout for the JP/EUC test.
+# A multiple of 3 seems to be enough for i5,i7, but AMD needs >25.
+timeout=$($AWK 'BEGIN { print 50 * ('$stop' - '$start')}' < /dev/null)
+
+test $st = 1 || fail=1
+
+require_JP_EUC_locale_
+
# Expect no match, i.e., exit status of 1. Anything else is an error.
-timeout 4 grep -i foobar in; st=$?
+timeout $timeout grep -i foobar in; st=$?
test $st = 1 || fail=1
Exit $fail