char * ops与std :: string的基准 [英] benchmarks of char* ops vs. std::string

查看:58
本文介绍了char * ops与std :: string的基准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在那里使用c

字符串和std :: string之间有什么不同的基准吗?谷歌对它不友好。

吧。显然这将取决于不同的实现,但

我不在乎。我很乐意在这一点上找到任何比较,如果

它是有效且半科学地完成的。

Are there any decent benchmarks of the difference between using c
strings and std::string out there? Google isn''t being friendly about
it. Obviously this would be dependant on different implementations but
I don''t care. I would be happy to find ANY comparison at this point if
it was valid and semi scientifically done.

推荐答案

roberts.n ... @ gmail.com写道:
roberts.n...@gmail.com wrote:
在那里使用c
字符串和std :: string之间有什么不同的基准吗?谷歌对它不友好。显然这将取决于不同的实现,但
我不在乎。如果它有效且半科学地完成,我很乐意找到任何比较。
Are there any decent benchmarks of the difference between using c
strings and std::string out there? Google isn''t being friendly about
it. Obviously this would be dependant on different implementations but
I don''t care. I would be happy to find ANY comparison at this point if
it was valid and semi scientifically done.




我没有给你答案,但我可以告诉你,大多数在C ++

社区认为std :: string的好处非常值得花费

(正如你所说,实现,但实际上通常是足够好,实际上是b $ b。实际上,这个小组的常见问题解答是这个小组认为阵列是邪恶的。比较:

http://www.parashift.com/c++-faq-lit....html#faq-17.5


干杯! --M



I don''t have an answer for you, but I can tell you that most in the C++
community think the benefits of std::string is well worth the cost
(which, as you say, varies between implementations but which is
pragmatically speaking usually "good enough"). In fact, the FAQ for
this group maintains that arrays are evil. Compare:

http://www.parashift.com/c++-faq-lit....html#faq-17.5

Cheers! --M




mlimber写道:

mlimber wrote:
roberts.n ... @ gmail。 com写道:
roberts.n...@gmail.com wrote:
在那里使用c
字符串和std :: string之间有什么不同的基准吗?谷歌对它不友好。显然这将取决于不同的实现,但
我不在乎。如果它有效且半科学地完成,我很乐意找到任何比较。
Are there any decent benchmarks of the difference between using c
strings and std::string out there? Google isn''t being friendly about
it. Obviously this would be dependant on different implementations but
I don''t care. I would be happy to find ANY comparison at this point if
it was valid and semi scientifically done.



我没有给你答案,但我可以告诉你,大多数C ++社区都认为std :: string的好处值得付出代价
(正如你所说的那样,实现之间有所不同,但实际上通常是说实用的) ;足够好)。事实上,这个小组的常见问题解答认为阵列是邪恶的。比较:

http://www.parashift.com/c++-faq-lit....html#faq-17.5




_I_知道,但是在我试图说服某人之前,这是一个真正的*死硬的粉丝*粉丝。是的,我花了8个小时,周六追逐

下来由char *引起的缓冲区溢出,但每次我使用std :: string

我都会遇到性能问题。我已经展示了很多

std :: string并没有出现在我做的配置文件中但它没有

我的影响喜欢。我需要一个基准才能令人信服。



_I_ know that, but as before I am trying to convince someone that is a
*really* die hard char* fan. Yes, I spent 8 hours yesturday chasing
down buffer overflows caused by char* but every time I use std::string
I get hastled about performance issues. I''ve shown a lot that
std::string isn''t showing up in the profiles I do but it isn''t having
the effect I wolud like. I need a benchmark to be at all convincing.



ro ********** @ gmail.com 写道:
是否有任何体面的基准测试使用c
字符串和std :: string在那里?谷歌对它不友好。显然这将取决于不同的实现,但
我不在乎。如果它有效且半科学地完成,我很乐意找到任何比较。
Are there any decent benchmarks of the difference between using c
strings and std::string out there? Google isn''t being friendly about
it. Obviously this would be dependant on different implementations but
I don''t care. I would be happy to find ANY comparison at this point if
it was valid and semi scientifically done.




i不知道任何具体的性能基准,可能

无论如何都没有多大意义。你可以肯定任何体面的STL

实现都会实现足够优化的字符串和分配

操作,这会让你很难在自定义中匹配

实现。


c ++性能报告给出了使用非虚拟类的(几乎没有b $ b不存在的)性能损失的硬数据。 (见
http://www.open-std.org/jtc1/sc22/wg...2002/n1396.pdf


如果您对您有特殊要求字符串操作

与您可能会调查实现的常见用例有很大不同。
a自定义分配器甚至是字符串类,但这不应该是

一般来说。


- 彼得



i don''t know of any concrete performance benchmarks, which probably
wouldn''t make much sense anyways. you can be sure that any decent STL
implementation implements sufficiently optimized string and allocation
operations which would give you a hard time to match in custom
implementations.

the c++ performance report gives hard figures of the (practically
non-existent) performance hit for using non-virtual classes. (see
http://www.open-std.org/jtc1/sc22/wg...2002/n1396.pdf)

if you have very special requirements for you string operations that
differ much from the common use case you might investigate implementing
a custom allocator or even string class, but that should not be
necessary in general.

-- peter


这篇关于char * ops与std :: string的基准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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