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

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

问题描述

我将创建一个使用字典查找和插入的项目。这是值得关注的吗?

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?

此外,我不认为我是微型优化,因为这真的将是生产服务器上代码的重要部分,因此如果这需要额外的100ms要完成,那么我们将会寻找新的方法来处理这个问题。

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. 微型优化。你甚至有工作代码吗?记住,如果它不起作用,快速不起作用就没关系。 (Mich Ravera) http://www.codingninja.co.uk/best-programmers-报价/

  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/.

您不知道瓶颈将在哪里,而您已经专注于Dictionary。如果问题在别的地方怎么办?

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

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

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天全站免登陆