VirtualBox

source: kBuild/trunk/src/grep/tests/long-pattern-perf@ 3646

Last change on this file since 3646 was 3529, checked in by bird, 3 years ago

Imported grep 3.7 from grep-3.7.tar.gz (sha256: c22b0cf2d4f6bbe599c902387e8058990e1eee99aef333a203829e5fd3dbb342), applying minimal auto-props.

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1#!/bin/sh
2# grep-2.21 would incur a 100x penalty for 10x increase in regexp length
3
4# Copyright 2015-2021 Free Software Foundation, Inc.
5
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19. "${srcdir=.}/init.sh"; path_prepend_ ../src
20
21fail=0
22
23# This test is susceptible to failure due to differences in
24# system load during the two test runs, so we'll mark it as
25# "expensive", making it less likely to be run by regular users.
26expensive_
27
28echo x > in || framework_failure_
29# Note that we want 10x the byte count (not line count) in the larger file.
30seq 10000 50000 | tr -d '\012' > r || framework_failure_
31cat r r r r r r r r r r > re-10x || framework_failure_
32mv r re || framework_failure_
33
34base_ms=$(user_time_ 1 grep -f re in ) || fail=1
35b10x_ms=$(user_time_ 1 grep -f re-10x in) || fail=1
36
37# Increasing the length of the regular expression by a factor
38# of 10 should cause no more than a 10x increase in duration.
39# However, we'll draw the line at 20x to avoid false-positives.
40returns_ 1 expr $base_ms '<' $b10x_ms / 20 || fail=1
41
42Exit $fail
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette