malloc和calloc [英] malloc and calloc

查看:77
本文介绍了malloc和calloc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪一个更快?

malloc后跟memset



calloc

Which one is more fast?
malloc followed by memset
or
calloc

推荐答案

2004年2月2日星期一02:41:31 -0800,Rahul Gandhi写道:
On Mon, 02 Feb 2004 02:41:31 -0800, Rahul Gandhi wrote:
哪一个更快?
malloc后跟memset

calloc
Which one is more fast?
malloc followed by memset
or
calloc




这取决于平台。如果有一个,它可能不会很重要。如果您认为现在是时候在目标平台上进行

测量了。


我不会惊讶地看到calloc实现只调用malloc和

然后memset。


-

NPV


大字打印,小字打印

Tom Waits - 向上走吧



That would depend on the plattform. If there is one it probably won''t be
big enough to matter. If you think it would then it''s time for you to make
measurements on your target platform.

I wouldn''t be surprised to see calloc implemented to just call malloc and
then memset.

--
NPV

"the large print giveth, and the small print taketh away"
Tom Waits - Step right up


Rahul Gandhi < GA ********* @ hotmail.com>在消息中写道

news:26 ************************** @ posting.google.c om ...
"Rahul Gandhi" <ga*********@hotmail.com> wrote in message
news:26**************************@posting.google.c om...
哪一个更快?
malloc后跟memset

calloc
Which one is more fast?
malloc followed by memset
or
calloc




红色功能往往会更快。但是你必须做一些分析才能确定每个函数的相应色度色调。


I.e.标准没有对功能施加速度​​要求。这是

''实施质量''问题。


-

彼得



Red functions tend to go faster. But you''ll have to do some profiling to
determine the appropriate chromodynamic hue of each function.

I.e. the standard doesn''t impose speed requirements on functions. It''s a
''Quality of Implementation'' issue.

--
Peter


ga*********@hotmail.com (Rahul Gandhi)在消息新闻中写道:< 26 ************************** @ posting.google。 com> ...
ga*********@hotmail.com (Rahul Gandhi) wrote in message news:<26**************************@posting.google. com>...
哪一个更快?
malloc后跟memset

calloc
Which one is more fast?
malloc followed by memset
or
calloc




它取决于平台。


但是你真的关心malloc的速度吗?如果你有你的b $ ba部分你的程序不是很好写的。


你也会发现它很常见''免费'到目前为止

最慢。



It is platform dependent.

But do you really care about the speed of malloc? If you do you have
a part of your program that''s not written very well.

You will also find that it''s quite common for ''free'' to be by far the
slowest.


这篇关于malloc和calloc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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