stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Black (JIRA)" <j...@apache.org>
Subject [jira] Updated: (STDCXX-518) std::string copy constructor slow
Date Mon, 24 Sep 2007 20:35:50 GMT

     [ https://issues.apache.org/jira/browse/STDCXX-518?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Andrew Black updated STDCXX-518:
--------------------------------

         Severity: Inefficiency
    Fix Version/s: 4.2.1

Updated Severity field to describe impact and scheduling for 4.2.1.  We aren't going to have
time to look into this this cycle, but it is best looked into sooner rather than later.

> std::string copy constructor slow
> ---------------------------------
>
>                 Key: STDCXX-518
>                 URL: https://issues.apache.org/jira/browse/STDCXX-518
>             Project: C++ Standard Library
>          Issue Type: Improvement
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: gcc 4.1.2, x86_64
>            Reporter: Mark Brown
>             Fix For: 4.2.1
>
>
> When thread safety is enabled in stdcxx the string copy constructor is more than ten
times slower than when it's not, and twice as slow as the same copy constructor in gcc 4.1.2
on Linux (x86_64), but slightly faster than with STLport 5.1.3. The timings were done on Intel
x86_64 at 2.4GHz:
> BUILDMODE=shared,optimized:
> $ time LD_LIBRARY_PATH=../lib ./string-copy 100000000
> real    0m0.482s
> user    0m0.480s
> sys     0m0.000s
> BUILDMODE=shared,optimized,pthread:
> $ time LD_LIBRARY_PATH=../lib ./string-copy 100000000
> real    0m10.157s
> user    0m10.041s
> sys     0m0.032s
> gcc 4.1.2 with -O2 -m64:
> $ time ./string-copy.gcc 100000000
> real    0m4.280s
> user    0m4.260s
> sys     0m0.020s
> gcc 4.1.2 with STLport 5.1.3 (-D_REENTRANT -O2 -m64 -lpthread):
> $ time ./string-copy.stlport 100000000
> real    0m12.479s
> user    0m12.473s
> sys     0m0.004s
> #include <cassert>
> #include <cstdlib>
> #include <string>
> int main (int argc, char *argv[])
> {
>     const unsigned long n = argc < 2 ? 0 : std::strtoul (argv [1], 0, 10);
>     std::string strings [256];
>     const std::size_t num_strings = sizeof strings / sizeof *strings;
>     for (unsigned long i = 0; i != num_strings; ++i)
>         strings [i].assign (i, 'x');
>     for (unsigned long i = 0; i < n; ++i) {
>         const std::size_t length = i % num_strings;
>         const std::string str (strings [length]);
>         assert (str.size () == length);
>     }
> }

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


Mime
View raw message