CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 4 of 4 FirstFirst 1234
Results 46 to 53 of 53
  1. #46
    Join Date
    Jul 2002
    Location
    St. Louis, MO
    Posts
    484

    Re: CString -vs- std:string ?

    Quote Originally Posted by Axter
    Well, then that's why we're getting different results, which is what I suspected.

    I'm not sure what code of yours you're talking about, so please post what code you think is valid again, and if it is valid, I'll run it.

    Why is it that you can't use the following code, which is a valid test with correct parameters:
    I did, with VC 7.1:

    Time duration is as follow:
    CString = 2579
    std::string = 2484
    Press any key to continue . . .

  2. #47
    Join Date
    Jan 2001
    Posts
    588

    Re: CString -vs- std:string ?

    Quote Originally Posted by Axter
    They're not running the last code I posted, which insures the results are release mdoe code.
    So untill I see the results of that code, I can't really consider they're post.
    Actually, I did run your code. The code that I compiled and posted the results of earlier was the test1.cpp file that Paul attached to message #28. It did have the release-mode check in place.

  3. #48
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: CString -vs- std:string ?

    Quote Originally Posted by Axter
    That looks like the results of running a debug version instead of a release compiled version.
    Nope. It was definitely release version.
    No third party libraries either.

    std::string is always faster.

  4. #49
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: CString -vs- std:string ?

    Quote Originally Posted by Axter
    Try running the last code I posted, that has a debug compile directive, that makes sure you're getting results for release version.
    Output from the new code

    Time duration is as follow:
    CString = 4036
    std::string = 4627
    Press any key to continue . . .

    The original code shows std:string to be faster.
    The new code shows CString to be faster.

    Both sets of code compiled as Release versions.


  5. #50
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: CString -vs- std:string ?

    If you disable exception handling in the project settings...

    Time duration is as follow:
    CString = 4246 <<<< Increase
    std::string = 4376 <<<< Decrease
    Press any key to continue . . .

  6. #51
    Join Date
    Jun 2011
    Posts
    1

    Re: CString -vs- std:string ?

    Looks like a very recent thread (only 7 years old, nothing compared to the cosmos)

    Mckenzie and Axter, you guys were using systems with different system configuration. That is probably the explanation.

  7. #52
    Join Date
    Aug 2000
    Location
    New Jersey
    Posts
    968

    Re: CString -vs- std:string ?

    I had tested it in several different systems, and they all gave similar results.

    However, this thread is out dated, and more than likely does not hold true for the current std::string implementation that comes with current version of VC++.
    David Maisonave
    Author of Policy Based Synchronized Smart Pointer
    http://axter.com/smartptr


    Top ten member of C++ Expert Exchange.
    C++ Topic Area

  8. #53
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: CString -vs- std:string ?

    Quote Originally Posted by Axter View Post
    However, this thread is out dated, and more than likely does not hold true for the current std::string implementation that comes with current version of VC++.
    If you are still curious (I know I would be), here are the results from VS2010 (running on Win7-64, if that matters):
    CString = 1623
    std::string = 624
    CString here is from ATL, not MFC.

    I haven’t looked at the code close enough yet, but just wanted to say that if you know implementation details of each of these classes, you could come up with the test that favors any one of them. IIRC, both Intel and AMD used that technique in the past.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

Page 4 of 4 FirstFirst 1234

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