是否有std :: string和c style string的系统性能比较? [英] Is there systematic performance comparison of std::string and c style string?

查看:83
本文介绍了是否有std :: string和c style string的系统性能比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有关于

std :: string和c style string之间性能差异的比较数据?或者也许如果有源代码

可用于在不同的编译器/平台上测量,用

系统方式?

解决方案

2007-08-11 16:10, yu **** @ sina .com 写道:


是否有关于

std :: string和c style string之间性能差异的比较数据?或者,如果有源代码

可以用于不同的编译器/平台上的measuer,那么系统地用什么?b $ b?



肯定有,谷歌是你的朋友。我相信如果你在搜索中包含

这个词,你会找到一些。但请记住,如果他们没有衡量你所需要的价格,那么世界上所有的基准并不意味着什么,所以不要寻找其他人的基准。 />
使用您需要运行的代码执行自己的操作。


-

Erik Wikstr ?? m


8月11日晚上10点19分,Erik Wikstr?m< Erik-wikst ... @ telia.comwrote:


在2007-08-11 16:10,yu _... @ sina.com写道:


是否有关于性能差异的比较数据

std :: string和c style string?或者,如果有源代码

可以用于不同的编译器/平台上的measuer,那么系统地用什么?b $ b?



肯定有,谷歌是你的朋友。我相信如果你在搜索中包含

这个词,你会找到一些。但请记住,如果他们没有衡量你所需要的价格,那么世界上所有的基准并不意味着什么,所以不要寻找其他人的基准。 />
使用您需要运行的代码执行自己的操作。


-

Erik Wikstr?m



感谢您的回复和建议。实际上我自己是prety

确信更喜欢std :: string,但这并不是我的同事们常见的感觉。这就是为什么我正在寻找坚实的证据来说服

的人。我用google搜索了一段时间,但是没找到我能直接使用的
。我可以用任何方式编写一些代码来比较功能

我们感兴趣,就像你建议的那样。


问候,

凯文


2007-08-12 11:35, yu * ***@sina.com 写道:


8月11日晚上10点19分,Erik Wikstr?m< Erik-wikst ...... @ telia.comwrote:


> 2007-08-11 16:10,yu _... @ sina.com写道:


是否有关于

std :: string和c style string之间性能差异的比较数据?或者,如果有源代码

可以用于不同的编译器/平台上的measuer,那么系统地用什么?b $ b?


肯定有,谷歌是你的朋友。我相信如果你在搜索中包含单词rope,你会找到一些。请记住,如果世界上所有基准测试并不意味着你不需要测量你需要什么,那么不要寻找其他人的基准测试
用代码执行你自己的基准测试你需要跑。

-
Erik Wikstr?m



感谢您的回复和建议。实际上我自己是prety

确信更喜欢std :: string,但这并不是我的同事们常见的感觉。这就是为什么我正在寻找坚实的证据来说服

的人。我用google搜索了一段时间,但是没找到我能直接使用的
。我可以用任何方式编写一些代码来比较功能

我们感兴趣,就像你建议的那样。



我可能会错过了解你的原始问题,我认为

你想知道哪个是最好的表现者在

中使用

使用(例如真正大量的字符串或非常大的字符串),这种情况下使用C字符串有时会有一些好处。


但是如果你的意思是一般使用std :: string和C-strings,那么我很难接受任何有利于争论的论据C字符串

但很容易找到std :: string的参数(易用性,没有

溢出的风险,没有手动分配内存等)。实际上

反对使用C字符串的一个非常好的论据是,大多数缓冲区

溢出攻击是由于C字符串使用不当造成的,如果是

std :: string已被使用,而代码本来会更简单

更安全。至于速度,我会说std :: string足够快,对于大多数用法来说是很好的,如果你的应用程序是一个例外,你可能会知道

它由于您已经完成的分析和基准测试。


-

Erik Wikstr?m


Is there any comparison data on perfomance difference between
std::string and c style string? Or maybe if there are source code
which could be used to measuer on different compiler/platform, in a
systematic way?

解决方案

On 2007-08-11 16:10, yu****@sina.com wrote:

Is there any comparison data on perfomance difference between
std::string and c style string? Or maybe if there are source code
which could be used to measuer on different compiler/platform, in a
systematic way?

Most certainly there is, google is your friend. I believe if you include
the word rope in the search you''ll find some. Remember though that all
the benchmarks in the world does not mean shit if they don''t measure
what you need, so instead of looking for other peoples benchmarks
perform your own with the code you need to run.

--
Erik Wikstr??m


On Aug 11, 10:19 pm, Erik Wikstr?m <Erik-wikst...@telia.comwrote:

On 2007-08-11 16:10, yu_...@sina.com wrote:

Is there any comparison data on perfomance difference between
std::string and c style string? Or maybe if there are source code
which could be used to measuer on different compiler/platform, in a
systematic way?


Most certainly there is, google is your friend. I believe if you include
the word rope in the search you''ll find some. Remember though that all
the benchmarks in the world does not mean shit if they don''t measure
what you need, so instead of looking for other peoples benchmarks
perform your own with the code you need to run.

--
Erik Wikstr?m

Thanks for your reply and suggestion. Actually I myself am prety
convinced to prefer std::string, but it''s simply not a common sense of
my colleagues. That''s why I''m searching for hard proofs to convince
people. I did googled for some time, but didn''t find what I can
directly use. Any way I could write some code to compare functionality
we are interested, just as you have suggested.

Regards,
Kevin


On 2007-08-12 11:35, yu****@sina.com wrote:

On Aug 11, 10:19 pm, Erik Wikstr?m <Erik-wikst...@telia.comwrote:

>On 2007-08-11 16:10, yu_...@sina.com wrote:

Is there any comparison data on perfomance difference between
std::string and c style string? Or maybe if there are source code
which could be used to measuer on different compiler/platform, in a
systematic way?


Most certainly there is, google is your friend. I believe if you include
the word rope in the search you''ll find some. Remember though that all
the benchmarks in the world does not mean shit if they don''t measure
what you need, so instead of looking for other peoples benchmarks
perform your own with the code you need to run.

--
Erik Wikstr?m


Thanks for your reply and suggestion. Actually I myself am prety
convinced to prefer std::string, but it''s simply not a common sense of
my colleagues. That''s why I''m searching for hard proofs to convince
people. I did googled for some time, but didn''t find what I can
directly use. Any way I could write some code to compare functionality
we are interested, just as you have suggested.

I might have miss understood you original question a bit, I thought that
you wanted to know which was the best performer for a certain kind of
use (such as really large amounts of strings or really large strings) in
which case there might sometimes be some benefits to using C-strings.

But if you mean usage of std::string vs. C-strings in general then I''m
very hard pressed to come up with any argument in favour of C-strings
but it''s quite easy to find arguments for std::string (ease of use, no
risk of overflows, don''t have to allocate memory manually etc.). In fact
one very good argument against using C-strings is that most buffer
overflow attacks are caused by improper usage of C-strings, and if
std::string had been used instead the code would have been much simpler
and more safe. As for speed, I''d say that std::string is fast enough for
most usages and if your application is an exception you''d probably know
it due to profiling and benchmarks you''ve already done.

--
Erik Wikstr?m


这篇关于是否有std :: string和c style string的系统性能比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆