public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/66414] New: Regression: string::find ten times slower than strstr
@ 2015-06-04  7:59 neleai at seznam dot cz
  2020-03-24 17:24 ` [Bug libstdc++/66414] " hiraditya at msn dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: neleai at seznam dot cz @ 2015-06-04  7:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66414

            Bug ID: 66414
           Summary: Regression: string::find ten times slower than strstr
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: neleai at seznam dot cz
  Target Milestone: ---

Hi, as I seen bug with string::== being slower than using strcmp I decided to
check other functions for regressions. Here string::find doesn't simply call
optimized strstr and as result its ten times slower in following benchmark on
my sandy bridge.


#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;

int
main()
{
  int i;
  char s[10000];
  for (i = 0; i < 10000; i++)
    s[i] = ((unsigned) rand() % 128) + 1;
  s[9999] = 0;
  int sum = 0;
  std::string foo = s;
  std::string bar;
  char *needle = strdup("needle");

  for (i = 0; i < 100000; i++)
    {
      needle[0] = ((unsigned) rand() % 128) + 1;
#ifdef STRSTR
      sum += (long) strstr(s, needle);
#else
      sum += foo.find(needle);
#endif
    }
  return sum;
}


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-09-12  7:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-04  7:59 [Bug libstdc++/66414] New: Regression: string::find ten times slower than strstr neleai at seznam dot cz
2020-03-24 17:24 ` [Bug libstdc++/66414] " hiraditya at msn dot com
2021-01-27 13:34 ` redi at gcc dot gnu.org
2021-01-27 13:47 ` cvs-commit at gcc dot gnu.org
2023-09-11 17:03 ` scc at teamt5 dot org
2023-09-11 17:03 ` scc at teamt5 dot org
2023-09-11 17:04 ` scc at teamt5 dot org
2023-09-11 17:22 ` scc at teamt5 dot org
2023-09-11 19:09 ` redi at gcc dot gnu.org
2023-09-12  2:55 ` scc at teamt5 dot org
2023-09-12  7:31 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).