Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #37363

Re: What practice can get speed improvement in C++?

From Bo Persson <bop@gmb.dk>
Newsgroups comp.lang.c++
Subject Re: What practice can get speed improvement in C++?
Date 2015-08-06 17:29 +0200
Message-ID <d2hcqmFlp2cU1@mid.individual.net> (permalink)
References (3 earlier) <mppslj$iam$1@adenine.netfront.net> <f76c748e-03ed-41ae-8e8c-6bd49b6f9f3c@googlegroups.com> <mpsggk$27e5$1@adenine.netfront.net> <df458bfc-ff61-40e1-b2cf-30782eb9f74b@googlegroups.com> <d2gadrFa455U2@mid.individual.net>

Show all headers | View raw


On 2015-08-06 07:42, Ian Collins wrote:
> woodbrian77@gmail.com wrote:
>>
>> How about comparing these two programs:
>>
>> #include <string.h>
>>
>> int main ()
>> {
>>    for (int i = 0; i < 4000000; ++i){
>>      char s[200];
>>      ::strncpy(s, "We few; we happy few; we band of brothers.",
>> sizeof(s));
>>    }
>> }
>>
>> and
>>
>> #include <string>
>>
>> int main ()
>> {
>>    for (int i = 0; i < 4000000; ++i){
>>      ::std::string s = "We few; we happy few; we band of brothers.";
>>    }
>> }
>
> A fairer comparison would be
>
> int main ()
> {
>    std::string s;
>    for (int i = 0; i < 4000000; ++i){
>      s = "We few; we happy few; we band of brothers.";
>    }
> }
>

Or try doing this with C strings:

int main ()
{
    std::string s;
    for (int i = 0; i < 4000000; ++i){
      s += "We few; we happy few; we band of brothers.";
    }
}



Bo Persson

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

What practice can get speed improvement in C++? fl <rxjwg98@gmail.com> - 2015-07-14 16:53 -0700
  Re: What practice can get speed improvement in C++? Barry Schwarz <schwarzb@dqel.com> - 2015-07-14 17:23 -0700
    Re: What practice can get speed improvement in C++? bartekltg <bartekltg@gmail.com> - 2015-07-15 15:10 +0200
      Re: What practice can get speed improvement in C++? JiiPee <no@notvalid.com> - 2015-07-16 05:00 +0100
        Re: What practice can get speed improvement in C++? Öö Tiib <ootiib@hot.ee> - 2015-07-16 01:04 -0700
          Re: What practice can get speed improvement in C++? JiiPee <no@notvalid.com> - 2015-07-16 16:48 +0100
            Re: What practice can get speed improvement in C++? JiiPee <no@notvalid.com> - 2015-07-16 16:52 +0100
        Re: What practice can get speed improvement in C++? bartekltg <bartekltg@gmail.com> - 2015-07-16 13:23 +0200
          Re: What practice can get speed improvement in C++? Öö Tiib <ootiib@hot.ee> - 2015-07-16 06:54 -0700
            Re: What practice can get speed improvement in C++? bartekltg <bartekltg@gmail.com> - 2015-07-16 17:30 +0200
              Re: What practice can get speed improvement in C++? Öö Tiib <ootiib@hot.ee> - 2015-07-16 11:16 -0700
                Re: What practice can get speed improvement in C++? bartekltg <bartekltg@gmail.com> - 2015-07-17 17:06 +0200
          Re: What practice can get speed improvement in C++? JiiPee <no@notvalid.com> - 2015-08-04 16:14 +0100
  Re: What practice can get speed improvement in C++? Victor Bazarov <v.bazarov@comcast.invalid> - 2015-07-14 20:29 -0400
    Re: What practice can get speed improvement in C++? woodbrian77@gmail.com - 2015-07-14 19:50 -0700
  Re: What practice can get speed improvement in C++? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2015-07-15 05:07 +0200
  Re: What practice can get speed improvement in C++? Lőrinczy Zsigmond <nospam@for.me> - 2015-07-15 06:38 +0200
  Re: What practice can get speed improvement in C++? Paavo Helde <myfirstname@osa.pri.ee> - 2015-07-15 00:22 -0500
    Re: What practice can get speed improvement in C++? fl <rxjwg98@gmail.com> - 2015-07-16 04:34 -0700
      Re: What practice can get speed improvement in C++? Martijn van Buul <pino@dohd.org> - 2015-07-21 09:28 +0000
  Re: What practice can get speed improvement in C++? Juha Nieminen <nospam@thanks.invalid> - 2015-08-03 08:16 +0000
    Re: What practice can get speed improvement in C++? woodbrian77@gmail.com - 2015-08-03 13:48 -0700
      Re: What practice can get speed improvement in C++? Juha Nieminen <nospam@thanks.invalid> - 2015-08-04 08:21 +0000
        Re: What practice can get speed improvement in C++? Öö Tiib <ootiib@hot.ee> - 2015-08-04 08:07 -0700
        Re: What practice can get speed improvement in C++? woodbrian77@gmail.com - 2015-08-04 10:15 -0700
          Re: What practice can get speed improvement in C++? Bo Persson <bop@gmb.dk> - 2015-08-04 20:09 +0200
            Re: What practice can get speed improvement in C++? woodbrian77@gmail.com - 2015-08-04 12:38 -0700
              Re: What practice can get speed improvement in C++? Bo Persson <bop@gmb.dk> - 2015-08-05 17:03 +0200
                Re: What practice can get speed improvement in C++? woodbrian77@gmail.com - 2015-08-05 23:32 -0700
            Re: What practice can get speed improvement in C++? Öö Tiib <ootiib@hot.ee> - 2015-08-05 03:55 -0700
          Re: What practice can get speed improvement in C++? Christopher Pisz <nospam@notanaddress.com> - 2015-08-04 14:09 -0500
            Re: What practice can get speed improvement in C++? woodbrian77@gmail.com - 2015-08-04 12:18 -0700
              Re: What practice can get speed improvement in C++? Christopher Pisz <nospam@notanaddress.com> - 2015-08-04 14:50 -0500
              Re: What practice can get speed improvement in C++? Öö Tiib <ootiib@hot.ee> - 2015-08-05 04:11 -0700
          Re: What practice can get speed improvement in C++? Juha Nieminen <nospam@thanks.invalid> - 2015-08-05 08:12 +0000
            Re: What practice can get speed improvement in C++? Martin Shobe <martin.shobe@yahoo.com> - 2015-08-05 08:53 -0500
            Re: What practice can get speed improvement in C++? woodbrian77@gmail.com - 2015-08-05 22:24 -0700
              Re: What practice can get speed improvement in C++? Ian Collins <ian-news@hotmail.com> - 2015-08-06 17:42 +1200
                Re: What practice can get speed improvement in C++? woodbrian77@gmail.com - 2015-08-05 22:53 -0700
                Re: What practice can get speed improvement in C++? Öö Tiib <ootiib@hot.ee> - 2015-08-06 00:20 -0700
                Re: What practice can get speed improvement in C++? Christopher Pisz <nospam@notanaddress.com> - 2015-08-06 10:10 -0500
                Re: What practice can get speed improvement in C++? Bo Persson <bop@gmb.dk> - 2015-08-06 17:29 +0200
                Re: What practice can get speed improvement in C++? woodbrian77@gmail.com - 2015-08-06 09:38 -0700
              Re: What practice can get speed improvement in C++? Juha Nieminen <nospam@thanks.invalid> - 2015-08-10 08:25 +0000
  Re: What practice can get speed improvement in C++? pip010 <pip010@gmail.com> - 2015-08-03 04:22 -0700

csiph-web