我应该关心的.NET字典的速度? [英] Should I be concerned about .NET dictionary speed?

查看:118
本文介绍了我应该关心的.NET字典的速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将创建一个将使用字典查找并插入相当多的项目。这是不是被关注?

另外,如果我不和基准等,这是非常糟糕的,那么什么是用别的东西代替的字典的最佳方式?会用一个哈希键数组甚至更快?这将不插入时会虽然它帮助吗?

另外,我不认为我是微优化,因为这真的将是code的生产服务器上显著的部分,因此,如果这需要一个额外的100毫秒内完成,那么我们将寻找新的方法来处理这​​个问题。


解决方案

  1. 您的的微型优化。你甚至有工作code吗?请记住,如果它不能正常工作,它并没有多么的快速的这是行不通的。 (密歇根州Ravera) http://www.codingninja.co.uk/best-programmers-报价/

    您不知道那里的瓶颈会,并且已经您关注的字典。如果有什么问题是别的地方?


  2. 你怎么知道如何Dictionary类中实现?也许它已经使用了一个数组哈希键!

P.S。这真是.NET字典,而不是C#字典,因为C#是只是其中使用的框架几种编程语言之一

I will be creating a project that will use dictionary lookups and inserts quite a bit. Is this something to be concerned about?

Also, if I do benchmarking and such and it is really bad, then what is the best way of replacing dictionary with something else? Would using an array with "hashed" keys even be faster? That wouldn't help on insert time though will it?

Also, I don't think I'm micro-optimizing because this really will be a significant part of code on a production server, so if this takes an extra 100ms to complete, then we will be looking for new ways to handle this.

解决方案

  1. You are micro-optimizing. Do you even have working code yet? Remember, "If it doesn't work, it doesn't matter how fast it doesn't work." (Mich Ravera) http://www.codingninja.co.uk/best-programmers-quotes/.

    You have no idea where the bottlenecks will be, and already you're focused on Dictionary. What if the problem is somewhere else?

  2. How do you know how the Dictionary class is implemented? Maybe it already uses an array with hashed keys!

P.S. It's really ".NET Dictionaries", not "C# Dictionaries", because C# is just one of several programming languages that use the framework.

这篇关于我应该关心的.NET字典的速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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