public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "neleai at seznam dot cz" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/66414] New: Regression: string::find ten times slower than strstr Date: Thu, 04 Jun 2015 07:59:00 -0000 [thread overview] Message-ID: <bug-66414-4@http.gcc.gnu.org/bugzilla/> (raw) 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; }
next reply other threads:[~2015-06-04 7:59 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-06-04 7:59 neleai at seznam dot cz [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-66414-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).