CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 53

Threaded View

  1. #10
    Join Date
    Apr 1999
    Posts
    27,449

    Re: CString -vs- std:string ?

    f you run the code below, you'll see the peformance difference between CString and std::string.
    Run the test in release mode (not debug).
    The code below will show that CString out peformance std::string by a factor of MORE then 10 to 1.
    Compile in VC++ 6.0 using std::string that comes with VC++.
    Do a reserve() on the string before using it. Then you should see hardly any difference.

    Almost all of the standard container classes, including std::string, has a reserve() method that addresses the issue that you demonstrated in your code. The ones that don't are the associative types (maps).

    In general, what usually ends up in real code is a series of many concatenations on one string. Why not run a benchmark on that, since that is what is more likely to be done in a real application.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; November 30th, 2004 at 06:34 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured