diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:21:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:21:29 +0000 |
commit | 29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc (patch) | |
tree | 63ef546b10a81d461e5cf5ed9e98a68cd7dee1aa /src/grep/tests/mb-non-UTF8-performance | |
parent | Initial commit. (diff) | |
download | kbuild-29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc.tar.xz kbuild-29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc.zip |
Adding upstream version 1:0.1.9998svn3589+dfsg.upstream/1%0.1.9998svn3589+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/grep/tests/mb-non-UTF8-performance')
-rwxr-xr-x | src/grep/tests/mb-non-UTF8-performance | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/grep/tests/mb-non-UTF8-performance b/src/grep/tests/mb-non-UTF8-performance new file mode 100755 index 0000000..a0e9b70 --- /dev/null +++ b/src/grep/tests/mb-non-UTF8-performance @@ -0,0 +1,48 @@ +#!/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-2021 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +fail=0 + +# This test is susceptible to failure due to differences in +# system load during the two test runs, so we'll mark it as +# "expensive", making it less likely to be run by regular users. +expensive_ + +# Make the input large enough so that even on high-end systems +# the unibyte test takes at least 10ms of user time. +n_lines=100000 +while :; do + yes $(printf '%078d' 0) | sed ${n_lines}q > in || framework_failure_ + ubyte_ms=$(LC_ALL=C user_time_ 1 grep -i foobar in) || fail=1 + test $ubyte_ms -ge 10 && break + n_lines=$(expr $n_lines + 200000) +done + +require_JP_EUC_locale_ +mbyte_ms=$(user_time_ 1 grep -i foobar in) || fail=1 + +# The duration of the multi-byte run must be no more than 30 times +# that of the single-byte one. +# A multiple of 3 seems to be enough for i5,i7, but AMD needs >25. +returns_ 1 expr $ubyte_ms '<' $mbyte_ms / 30 || fail=1 + +Exit $fail |