You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Mark Brown (JIRA)" <ji...@apache.org> on 2007/07/23 00:14:31 UTC

[jira] Created: (STDCXX-493) std::string::append() slow

std::string::append() slow
--------------------------

                 Key: STDCXX-493
                 URL: https://issues.apache.org/jira/browse/STDCXX-493
             Project: C++ Standard Library
          Issue Type: Bug
          Components: 21. Strings
    Affects Versions: 4.1.3
         Environment: gcc 4.1.2 on Linux/x86_64
            Reporter: Mark Brown


This is a similar problem to STDCXX-492: all overloads of string::append() are slower than the same overloads in gcc:

$ let n=0; while [ $n -lt 3 ]; do time LD_LIBRARY_PATH=../lib ./append-stdcxx-4.1.3 500000000 $n; let n=`expr $n + 1`; done

real    0m11.221s
user    0m9.941s
sys     0m1.104s

real    0m13.065s
user    0m11.661s
sys     0m1.236s

real    0m7.837s
user    0m6.660s
sys     0m1.160s

$ let n=0; while [ $n -lt 3 ]; do time ./append-gcc-4.1.2 500000000 $n; let n=`expr $n + 1`; done

real    0m4.865s
user    0m4.172s
sys     0m0.692s

real    0m7.617s
user    0m6.920s
sys     0m0.696s

real    0m5.787s
user    0m5.068s
sys     0m0.720s

The program I used to do the comaprison is below:

#include <cassert>
#include <cstdlib>
#include <string>

int main (int argc, char *argv[])
{
    const int N = argc < 2 ? 1 : std::atoi (argv [1]);
    const int op = argc < 3 ? 0 : std::atoi (argv [2]);

    std::string str;

    const std::string x ("X");

    if (op == 0) {
        for (int i = 0; i < N; ++i)
            str.append (1, 'x');
    } else if (op == 1) {
        for (int i = 0; i < N; ++i)
            str.append ("x");
    } else {
        for (int i = 0; i < N; ++i)
            str.append (x);
    }

    assert (str.size () == std::size_t (N));
}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STDCXX-493) std::string::append() slow

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12526581 ] 

Martin Sebor commented on STDCXX-493:
-------------------------------------

If you modified the patch in a substantive way you should add yourself to the ChangeLog.

> std::string::append() slow
> --------------------------
>
>                 Key: STDCXX-493
>                 URL: https://issues.apache.org/jira/browse/STDCXX-493
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: gcc 4.1.2 on Linux/x86_64
>            Reporter: Mark Brown
>            Assignee: Travis Vitek
>             Fix For: 4.2
>
>         Attachments: stdcxx-493.patch
>
>
> This is a similar problem to STDCXX-492: all overloads of string::append() are slower than the same overloads in gcc:
> $ let n=0; while [ $n -lt 3 ]; do time LD_LIBRARY_PATH=../lib ./append-stdcxx-4.1.3 500000000 $n; let n=`expr $n + 1`; done
> real    0m11.221s
> user    0m9.941s
> sys     0m1.104s
> real    0m13.065s
> user    0m11.661s
> sys     0m1.236s
> real    0m7.837s
> user    0m6.660s
> sys     0m1.160s
> $ let n=0; while [ $n -lt 3 ]; do time ./append-gcc-4.1.2 500000000 $n; let n=`expr $n + 1`; done
> real    0m4.865s
> user    0m4.172s
> sys     0m0.692s
> real    0m7.617s
> user    0m6.920s
> sys     0m0.696s
> real    0m5.787s
> user    0m5.068s
> sys     0m0.720s
> The program I used to do the comaprison is below:
> #include <cassert>
> #include <cstdlib>
> #include <string>
> int main (int argc, char *argv[])
> {
>     const int N = argc < 2 ? 1 : std::atoi (argv [1]);
>     const int op = argc < 3 ? 0 : std::atoi (argv [2]);
>     std::string str;
>     const std::string x ("X");
>     if (op == 0) {
>         for (int i = 0; i < N; ++i)
>             str.append (1, 'x');
>     } else if (op == 1) {
>         for (int i = 0; i < N; ++i)
>             str.append ("x");
>     } else {
>         for (int i = 0; i < N; ++i)
>             str.append (x);
>     }
>     assert (str.size () == std::size_t (N));
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (STDCXX-493) std::string::append() slow

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor updated STDCXX-493:
--------------------------------

    Fix Version/s: 4.2

(Tentatively) scheduled for 4.2.

> std::string::append() slow
> --------------------------
>
>                 Key: STDCXX-493
>                 URL: https://issues.apache.org/jira/browse/STDCXX-493
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: gcc 4.1.2 on Linux/x86_64
>            Reporter: Mark Brown
>            Assignee: Travis Vitek
>             Fix For: 4.2
>
>
> This is a similar problem to STDCXX-492: all overloads of string::append() are slower than the same overloads in gcc:
> $ let n=0; while [ $n -lt 3 ]; do time LD_LIBRARY_PATH=../lib ./append-stdcxx-4.1.3 500000000 $n; let n=`expr $n + 1`; done
> real    0m11.221s
> user    0m9.941s
> sys     0m1.104s
> real    0m13.065s
> user    0m11.661s
> sys     0m1.236s
> real    0m7.837s
> user    0m6.660s
> sys     0m1.160s
> $ let n=0; while [ $n -lt 3 ]; do time ./append-gcc-4.1.2 500000000 $n; let n=`expr $n + 1`; done
> real    0m4.865s
> user    0m4.172s
> sys     0m0.692s
> real    0m7.617s
> user    0m6.920s
> sys     0m0.696s
> real    0m5.787s
> user    0m5.068s
> sys     0m0.720s
> The program I used to do the comaprison is below:
> #include <cassert>
> #include <cstdlib>
> #include <string>
> int main (int argc, char *argv[])
> {
>     const int N = argc < 2 ? 1 : std::atoi (argv [1]);
>     const int op = argc < 3 ? 0 : std::atoi (argv [2]);
>     std::string str;
>     const std::string x ("X");
>     if (op == 0) {
>         for (int i = 0; i < N; ++i)
>             str.append (1, 'x');
>     } else if (op == 1) {
>         for (int i = 0; i < N; ++i)
>             str.append ("x");
>     } else {
>         for (int i = 0; i < N; ++i)
>             str.append (x);
>     }
>     assert (str.size () == std::size_t (N));
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STDCXX-493) std::string::append() slow

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12526617 ] 

Martin Sebor commented on STDCXX-493:
-------------------------------------

I see. In that case you need to add yourself.

To attribute a change to two or more authors you just list their names, one per line, with the second and subsequent ones indented by a <TAB> and four spaces to line it up with the one above it (assuming tabs every 8 columns), like this:

2007-09-11<SP><SP>John Doe<SP...@doe.com>
<TAB><SP><SP><SP><SP>Jane Doe<SP...@doe.com>

<TAB>STDCXX-493
<TAB>*<SP>string (append): replace calls to replace with calls
<TAB>to append to improve performance.

> std::string::append() slow
> --------------------------
>
>                 Key: STDCXX-493
>                 URL: https://issues.apache.org/jira/browse/STDCXX-493
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: gcc 4.1.2 on Linux/x86_64
>            Reporter: Mark Brown
>            Assignee: Travis Vitek
>             Fix For: 4.2
>
>         Attachments: stdcxx-493.patch
>
>
> This is a similar problem to STDCXX-492: all overloads of string::append() are slower than the same overloads in gcc:
> $ let n=0; while [ $n -lt 3 ]; do time LD_LIBRARY_PATH=../lib ./append-stdcxx-4.1.3 500000000 $n; let n=`expr $n + 1`; done
> real    0m11.221s
> user    0m9.941s
> sys     0m1.104s
> real    0m13.065s
> user    0m11.661s
> sys     0m1.236s
> real    0m7.837s
> user    0m6.660s
> sys     0m1.160s
> $ let n=0; while [ $n -lt 3 ]; do time ./append-gcc-4.1.2 500000000 $n; let n=`expr $n + 1`; done
> real    0m4.865s
> user    0m4.172s
> sys     0m0.692s
> real    0m7.617s
> user    0m6.920s
> sys     0m0.696s
> real    0m5.787s
> user    0m5.068s
> sys     0m0.720s
> The program I used to do the comaprison is below:
> #include <cassert>
> #include <cstdlib>
> #include <string>
> int main (int argc, char *argv[])
> {
>     const int N = argc < 2 ? 1 : std::atoi (argv [1]);
>     const int op = argc < 3 ? 0 : std::atoi (argv [2]);
>     std::string str;
>     const std::string x ("X");
>     if (op == 0) {
>         for (int i = 0; i < N; ++i)
>             str.append (1, 'x');
>     } else if (op == 1) {
>         for (int i = 0; i < N; ++i)
>             str.append ("x");
>     } else {
>         for (int i = 0; i < N; ++i)
>             str.append (x);
>     }
>     assert (str.size () == std::size_t (N));
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (STDCXX-493) std::string::append() slow

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-493:
--------------------------------

    Attachment: stdcxx-493.patch

Yes, I believe that this patch is good. It doesn't cause any regressions, and the performance is significantly improved for one of the cases in the test [op == 1]. I see similar results on windows. I'm attaching an updated patch that can be applied more easily.

2007-09-07  Mark Brown <mb...@inbox.com>

	STDCXX-493
	string (append): replace calls to replace with calls
	to append to improve performance.

> std::string::append() slow
> --------------------------
>
>                 Key: STDCXX-493
>                 URL: https://issues.apache.org/jira/browse/STDCXX-493
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: gcc 4.1.2 on Linux/x86_64
>            Reporter: Mark Brown
>            Assignee: Travis Vitek
>             Fix For: 4.2
>
>         Attachments: stdcxx-493.patch
>
>
> This is a similar problem to STDCXX-492: all overloads of string::append() are slower than the same overloads in gcc:
> $ let n=0; while [ $n -lt 3 ]; do time LD_LIBRARY_PATH=../lib ./append-stdcxx-4.1.3 500000000 $n; let n=`expr $n + 1`; done
> real    0m11.221s
> user    0m9.941s
> sys     0m1.104s
> real    0m13.065s
> user    0m11.661s
> sys     0m1.236s
> real    0m7.837s
> user    0m6.660s
> sys     0m1.160s
> $ let n=0; while [ $n -lt 3 ]; do time ./append-gcc-4.1.2 500000000 $n; let n=`expr $n + 1`; done
> real    0m4.865s
> user    0m4.172s
> sys     0m0.692s
> real    0m7.617s
> user    0m6.920s
> sys     0m0.696s
> real    0m5.787s
> user    0m5.068s
> sys     0m0.720s
> The program I used to do the comaprison is below:
> #include <cassert>
> #include <cstdlib>
> #include <string>
> int main (int argc, char *argv[])
> {
>     const int N = argc < 2 ? 1 : std::atoi (argv [1]);
>     const int op = argc < 3 ? 0 : std::atoi (argv [2]);
>     std::string str;
>     const std::string x ("X");
>     if (op == 0) {
>         for (int i = 0; i < N; ++i)
>             str.append (1, 'x');
>     } else if (op == 1) {
>         for (int i = 0; i < N; ++i)
>             str.append ("x");
>     } else {
>         for (int i = 0; i < N; ++i)
>             str.append (x);
>     }
>     assert (str.size () == std::size_t (N));
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STDCXX-493) std::string::append() slow

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12526618 ] 

Martin Sebor commented on STDCXX-493:
-------------------------------------

I meant "you DON'T need to add yourself."

> std::string::append() slow
> --------------------------
>
>                 Key: STDCXX-493
>                 URL: https://issues.apache.org/jira/browse/STDCXX-493
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: gcc 4.1.2 on Linux/x86_64
>            Reporter: Mark Brown
>            Assignee: Travis Vitek
>             Fix For: 4.2
>
>         Attachments: stdcxx-493.patch
>
>
> This is a similar problem to STDCXX-492: all overloads of string::append() are slower than the same overloads in gcc:
> $ let n=0; while [ $n -lt 3 ]; do time LD_LIBRARY_PATH=../lib ./append-stdcxx-4.1.3 500000000 $n; let n=`expr $n + 1`; done
> real    0m11.221s
> user    0m9.941s
> sys     0m1.104s
> real    0m13.065s
> user    0m11.661s
> sys     0m1.236s
> real    0m7.837s
> user    0m6.660s
> sys     0m1.160s
> $ let n=0; while [ $n -lt 3 ]; do time ./append-gcc-4.1.2 500000000 $n; let n=`expr $n + 1`; done
> real    0m4.865s
> user    0m4.172s
> sys     0m0.692s
> real    0m7.617s
> user    0m6.920s
> sys     0m0.696s
> real    0m5.787s
> user    0m5.068s
> sys     0m0.720s
> The program I used to do the comaprison is below:
> #include <cassert>
> #include <cstdlib>
> #include <string>
> int main (int argc, char *argv[])
> {
>     const int N = argc < 2 ? 1 : std::atoi (argv [1]);
>     const int op = argc < 3 ? 0 : std::atoi (argv [2]);
>     std::string str;
>     const std::string x ("X");
>     if (op == 0) {
>         for (int i = 0; i < N; ++i)
>             str.append (1, 'x');
>     } else if (op == 1) {
>         for (int i = 0; i < N; ++i)
>             str.append ("x");
>     } else {
>         for (int i = 0; i < N; ++i)
>             str.append (x);
>     }
>     assert (str.size () == std::size_t (N));
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (STDCXX-493) std::string::append() slow

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor reassigned STDCXX-493:
-----------------------------------

    Assignee: Travis Vitek

Travis, can you check out Mark's patch and see if it is doable for 4.2?

> std::string::append() slow
> --------------------------
>
>                 Key: STDCXX-493
>                 URL: https://issues.apache.org/jira/browse/STDCXX-493
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: gcc 4.1.2 on Linux/x86_64
>            Reporter: Mark Brown
>            Assignee: Travis Vitek
>             Fix For: 4.2
>
>
> This is a similar problem to STDCXX-492: all overloads of string::append() are slower than the same overloads in gcc:
> $ let n=0; while [ $n -lt 3 ]; do time LD_LIBRARY_PATH=../lib ./append-stdcxx-4.1.3 500000000 $n; let n=`expr $n + 1`; done
> real    0m11.221s
> user    0m9.941s
> sys     0m1.104s
> real    0m13.065s
> user    0m11.661s
> sys     0m1.236s
> real    0m7.837s
> user    0m6.660s
> sys     0m1.160s
> $ let n=0; while [ $n -lt 3 ]; do time ./append-gcc-4.1.2 500000000 $n; let n=`expr $n + 1`; done
> real    0m4.865s
> user    0m4.172s
> sys     0m0.692s
> real    0m7.617s
> user    0m6.920s
> sys     0m0.696s
> real    0m5.787s
> user    0m5.068s
> sys     0m0.720s
> The program I used to do the comaprison is below:
> #include <cassert>
> #include <cstdlib>
> #include <string>
> int main (int argc, char *argv[])
> {
>     const int N = argc < 2 ? 1 : std::atoi (argv [1]);
>     const int op = argc < 3 ? 0 : std::atoi (argv [2]);
>     std::string str;
>     const std::string x ("X");
>     if (op == 0) {
>         for (int i = 0; i < N; ++i)
>             str.append (1, 'x');
>     } else if (op == 1) {
>         for (int i = 0; i < N; ++i)
>             str.append ("x");
>     } else {
>         for (int i = 0; i < N; ++i)
>             str.append (x);
>     }
>     assert (str.size () == std::size_t (N));
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (STDCXX-493) std::string::append() slow

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor closed STDCXX-493.
-------------------------------


> std::string::append() slow
> --------------------------
>
>                 Key: STDCXX-493
>                 URL: https://issues.apache.org/jira/browse/STDCXX-493
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: gcc 4.1.2 on Linux/x86_64
>            Reporter: Mark Brown
>            Assignee: Travis Vitek
>             Fix For: 4.2
>
>         Attachments: stdcxx-493.patch
>
>
> This is a similar problem to STDCXX-492: all overloads of string::append() are slower than the same overloads in gcc:
> $ let n=0; while [ $n -lt 3 ]; do time LD_LIBRARY_PATH=../lib ./append-stdcxx-4.1.3 500000000 $n; let n=`expr $n + 1`; done
> real    0m11.221s
> user    0m9.941s
> sys     0m1.104s
> real    0m13.065s
> user    0m11.661s
> sys     0m1.236s
> real    0m7.837s
> user    0m6.660s
> sys     0m1.160s
> $ let n=0; while [ $n -lt 3 ]; do time ./append-gcc-4.1.2 500000000 $n; let n=`expr $n + 1`; done
> real    0m4.865s
> user    0m4.172s
> sys     0m0.692s
> real    0m7.617s
> user    0m6.920s
> sys     0m0.696s
> real    0m5.787s
> user    0m5.068s
> sys     0m0.720s
> The program I used to do the comaprison is below:
> #include <cassert>
> #include <cstdlib>
> #include <string>
> int main (int argc, char *argv[])
> {
>     const int N = argc < 2 ? 1 : std::atoi (argv [1]);
>     const int op = argc < 3 ? 0 : std::atoi (argv [2]);
>     std::string str;
>     const std::string x ("X");
>     if (op == 0) {
>         for (int i = 0; i < N; ++i)
>             str.append (1, 'x');
>     } else if (op == 1) {
>         for (int i = 0; i < N; ++i)
>             str.append ("x");
>     } else {
>         for (int i = 0; i < N; ++i)
>             str.append (x);
>     }
>     assert (str.size () == std::size_t (N));
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STDCXX-493) std::string::append() slow

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12525727 ] 

Martin Sebor commented on STDCXX-493:
-------------------------------------

See http://www.mail-archive.com/stdcxx-dev@incubator.apache.org/msg04297.html

> std::string::append() slow
> --------------------------
>
>                 Key: STDCXX-493
>                 URL: https://issues.apache.org/jira/browse/STDCXX-493
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: gcc 4.1.2 on Linux/x86_64
>            Reporter: Mark Brown
>
> This is a similar problem to STDCXX-492: all overloads of string::append() are slower than the same overloads in gcc:
> $ let n=0; while [ $n -lt 3 ]; do time LD_LIBRARY_PATH=../lib ./append-stdcxx-4.1.3 500000000 $n; let n=`expr $n + 1`; done
> real    0m11.221s
> user    0m9.941s
> sys     0m1.104s
> real    0m13.065s
> user    0m11.661s
> sys     0m1.236s
> real    0m7.837s
> user    0m6.660s
> sys     0m1.160s
> $ let n=0; while [ $n -lt 3 ]; do time ./append-gcc-4.1.2 500000000 $n; let n=`expr $n + 1`; done
> real    0m4.865s
> user    0m4.172s
> sys     0m0.692s
> real    0m7.617s
> user    0m6.920s
> sys     0m0.696s
> real    0m5.787s
> user    0m5.068s
> sys     0m0.720s
> The program I used to do the comaprison is below:
> #include <cassert>
> #include <cstdlib>
> #include <string>
> int main (int argc, char *argv[])
> {
>     const int N = argc < 2 ? 1 : std::atoi (argv [1]);
>     const int op = argc < 3 ? 0 : std::atoi (argv [2]);
>     std::string str;
>     const std::string x ("X");
>     if (op == 0) {
>         for (int i = 0; i < N; ++i)
>             str.append (1, 'x');
>     } else if (op == 1) {
>         for (int i = 0; i < N; ++i)
>             str.append ("x");
>     } else {
>         for (int i = 0; i < N; ++i)
>             str.append (x);
>     }
>     assert (str.size () == std::size_t (N));
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (STDCXX-493) std::string::append() slow

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor resolved STDCXX-493.
---------------------------------

    Resolution: Fixed

Resolved by the committed patch. The before and after timings posted below indicate the patch makes the append(const_pointer) overload up to seven times faster than in 4.1.3.
http://www.mail-archive.com/stdcxx-dev@incubator.apache.org/msg03995.html

> std::string::append() slow
> --------------------------
>
>                 Key: STDCXX-493
>                 URL: https://issues.apache.org/jira/browse/STDCXX-493
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: gcc 4.1.2 on Linux/x86_64
>            Reporter: Mark Brown
>            Assignee: Travis Vitek
>             Fix For: 4.2
>
>         Attachments: stdcxx-493.patch
>
>
> This is a similar problem to STDCXX-492: all overloads of string::append() are slower than the same overloads in gcc:
> $ let n=0; while [ $n -lt 3 ]; do time LD_LIBRARY_PATH=../lib ./append-stdcxx-4.1.3 500000000 $n; let n=`expr $n + 1`; done
> real    0m11.221s
> user    0m9.941s
> sys     0m1.104s
> real    0m13.065s
> user    0m11.661s
> sys     0m1.236s
> real    0m7.837s
> user    0m6.660s
> sys     0m1.160s
> $ let n=0; while [ $n -lt 3 ]; do time ./append-gcc-4.1.2 500000000 $n; let n=`expr $n + 1`; done
> real    0m4.865s
> user    0m4.172s
> sys     0m0.692s
> real    0m7.617s
> user    0m6.920s
> sys     0m0.696s
> real    0m5.787s
> user    0m5.068s
> sys     0m0.720s
> The program I used to do the comaprison is below:
> #include <cassert>
> #include <cstdlib>
> #include <string>
> int main (int argc, char *argv[])
> {
>     const int N = argc < 2 ? 1 : std::atoi (argv [1]);
>     const int op = argc < 3 ? 0 : std::atoi (argv [2]);
>     std::string str;
>     const std::string x ("X");
>     if (op == 0) {
>         for (int i = 0; i < N; ++i)
>             str.append (1, 'x');
>     } else if (op == 1) {
>         for (int i = 0; i < N; ++i)
>             str.append ("x");
>     } else {
>         for (int i = 0; i < N; ++i)
>             str.append (x);
>     }
>     assert (str.size () == std::size_t (N));
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STDCXX-493) std::string::append() slow

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12526590 ] 

Travis Vitek commented on STDCXX-493:
-------------------------------------

All I did was merge the patch with the current version of the affected file. This was necessary so that I could test the patch. If you want the original patch, it can be found via the link you posted above.

Since you've mentioned it, how would one go about _adding_ themselves to the ChangeLog? I've only seen entries with one author and it might be useful to know what the expected format is for the future.

> std::string::append() slow
> --------------------------
>
>                 Key: STDCXX-493
>                 URL: https://issues.apache.org/jira/browse/STDCXX-493
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: gcc 4.1.2 on Linux/x86_64
>            Reporter: Mark Brown
>            Assignee: Travis Vitek
>             Fix For: 4.2
>
>         Attachments: stdcxx-493.patch
>
>
> This is a similar problem to STDCXX-492: all overloads of string::append() are slower than the same overloads in gcc:
> $ let n=0; while [ $n -lt 3 ]; do time LD_LIBRARY_PATH=../lib ./append-stdcxx-4.1.3 500000000 $n; let n=`expr $n + 1`; done
> real    0m11.221s
> user    0m9.941s
> sys     0m1.104s
> real    0m13.065s
> user    0m11.661s
> sys     0m1.236s
> real    0m7.837s
> user    0m6.660s
> sys     0m1.160s
> $ let n=0; while [ $n -lt 3 ]; do time ./append-gcc-4.1.2 500000000 $n; let n=`expr $n + 1`; done
> real    0m4.865s
> user    0m4.172s
> sys     0m0.692s
> real    0m7.617s
> user    0m6.920s
> sys     0m0.696s
> real    0m5.787s
> user    0m5.068s
> sys     0m0.720s
> The program I used to do the comaprison is below:
> #include <cassert>
> #include <cstdlib>
> #include <string>
> int main (int argc, char *argv[])
> {
>     const int N = argc < 2 ? 1 : std::atoi (argv [1]);
>     const int op = argc < 3 ? 0 : std::atoi (argv [2]);
>     std::string str;
>     const std::string x ("X");
>     if (op == 0) {
>         for (int i = 0; i < N; ++i)
>             str.append (1, 'x');
>     } else if (op == 1) {
>         for (int i = 0; i < N; ++i)
>             str.append ("x");
>     } else {
>         for (int i = 0; i < N; ++i)
>             str.append (x);
>     }
>     assert (str.size () == std::size_t (N));
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.