泛型&哈希表(表演) [英] Generics & Hashtables (Performance)
问题描述
您好!
既然已经在下一版C#中引入了泛型,那我就想知道我们将会有什么样的性能提升从例如切换
时看支持(或实现)的哈希表的一般哈希表
泛型?
我没有尝试过泛型,但我会认为一旦你不再需要b $ b必须再进行投射,事情可能会加速。
有何评论?
>
提前致谢!
-
venlig hilsen /关心
anders borum
-
Hello!
Now that generics are introduces with the next version of C#, I was
wondering what kind of performance gains we''re going to see, when switching
from e.g. the general hashtable to a hashtable that supports (or implements)
generics?
I haven''t tried generics hands-on, but I would assume that once you don''t
have to do casting anymore, things could speed up quite a bit.
Any comments?
Thanks in advance!
--
venlig hilsen / with regards
anders borum
--
推荐答案
Anders Borum< a@b.dk>写道:
Anders Borum <a@b.dk> wrote:
现在,随着C#的下一个版本引入了泛型,我想知道我们将会看到什么样的性能提升,例如从...支持(或实现)
泛型的哈希表的一般哈希表?
我没有尝试过仿制药,但我会假设一旦你没有不得不再做铸造,事情可能会加速很多。
Now that generics are introduces with the next version of C#, I was
wondering what kind of performance gains we''re going to see, when switching
from e.g. the general hashtable to a hashtable that supports (or implements)
generics?
I haven''t tried generics hands-on, but I would assume that once you don''t
have to do casting anymore, things could speed up quite a bit.
铸造相对便宜。如果你有(比方说)一个Hashtable映射字节,那么显着加快速度的是
缺乏拳击 - > byte,
或字节数组。
-
Jon Skeet - < sk *** @ pobox。 com>
http://www.pobox.com/~skeet
如果回复小组,请不要给我发邮件
Casting is relatively cheap. What will speed things up significantly is
the lack of boxing if you have (say) a Hashtable mapping byte -> byte,
or an ArrayList of bytes.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
" Jon Skeet [C#MVP]" < SK *** @ pobox.com>写在
新闻:MP ************************ @ msnews.microsoft.c om ...
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om...
Anders Borum< a@b.dk>写道:
Anders Borum <a@b.dk> wrote:
现在,随着C#的下一个版本引入了泛型,我想知道当
从例如切换时,我们会看到什么样的性能提升。支持(或
实现)泛型的哈希表的一般哈希表?
我没有尝试过仿制药,但我会假设一旦你用
don'不得不再做铸造,事情可能会加速很多。
Now that generics are introduces with the next version of C#, I was
wondering what kind of performance gains we''re going to see, when switching from e.g. the general hashtable to a hashtable that supports (or implements) generics?
I haven''t tried generics hands-on, but I would assume that once you don''t have to do casting anymore, things could speed up quite a bit.
铸造相对便宜。如果你有(比方说)一个Hashtable映射字节,那么显着加快速度的是没有拳击 - >字节,
或字节的ArrayList。
Casting is relatively cheap. What will speed things up significantly is
the lack of boxing if you have (say) a Hashtable mapping byte -> byte,
or an ArrayList of bytes.
但是,如果您的应用程序没有花费一半的时间在哈希表中,并且
arraylist-lookups,不要指望任何明显的速度提升。
Niki
Still, if your application doesn''t spend half of it''s time in hashtable- and
arraylist-lookups, don''t expect any noticeable speed improvement.
Niki
" Jon Skeet [C#MVP]" < SK *** @ pobox.com>在消息中写道
新闻:MP ************************ @ msnews.microsoft.c om ...
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Anders Borum< a@b.dk>写道:
Anders Borum <a@b.dk> wrote:
现在,随着C#的下一个版本引入了泛型,我想知道当
从例如切换时,我们会看到什么样的性能提升。支持(或
实现)泛型的哈希表的一般哈希表?
我没有尝试过仿制药,但我会假设一旦你用
don'不得不再做铸造,事情可能会加速很多。
Now that generics are introduces with the next version of C#, I was
wondering what kind of performance gains we''re going to see, when switching from e.g. the general hashtable to a hashtable that supports (or implements) generics?
I haven''t tried generics hands-on, but I would assume that once you don''t have to do casting anymore, things could speed up quite a bit.
铸造相对便宜。如果你有(比方说)一个Hashtable映射字节,那么显着加快速度的是没有拳击 - >字节,
或字节的ArrayList。
Casting is relatively cheap. What will speed things up significantly is
the lack of boxing if you have (say) a Hashtable mapping byte -> byte,
or an ArrayList of bytes.
如果我理解正确,泛型不会解决
$ b $的错误行为b容器中的结构。也就是说,给出一个带有x和y
坐标的点列表,
list.Get(i).x = 12;
仍会创建并修改结构的临时实例,并且不会修改列表中的实例。
If I understand things correctly, generics won''t solve the misbehavior of
structures in containers. That is, given a list of points with x and y
co-ordinates,
list.Get(i).x = 12;
still creates and modifies a temporary instance of the structure, and does
not modify the instance in the list.
这篇关于泛型&哈希表(表演)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!