字典的大小 [英] Size of a dictionary

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

问题描述

我目前正在设计在C#中的网站,它使用了一些非常复杂的代码来生成一个搜索列表,我目前设计为一个树状结构。

I am currently designing a website in C#, which uses some very complex code to generate a search list, which I am currently designing as a Tree-like structure.

我使用的是树的主要原因是,这个网站是高流量,有一个非常复杂的搜索过滤器,这意味着可扩展性是非常重要的,但是我担心树的内存需求可能会超过有效处理简单地每次重新计算值的要求。

The main reason I am using a tree is the fact that this website is high-traffic and has a very complex search filter, which means scalability is very important, however I am worried that the memory requirements of the tree may outweigh the effective processing requirements of simply recalculating values every time.

有谁知道来衡量在C#中的字典大小的可靠途径?
的Marshal.SizeOf()方法将不允许以此为代码不是非托管。

Does anyone know of a reliable way to measure the size of a dictionary in C#? The Marshal.SizeOf() method will not allow this as the code is not unmanaged.

干杯,埃德

推荐答案

最好的办法是根据不同的车型在网站上运行负荷和检查的相关性能计数器的。

best bet is to run load on the site under different models and check the relevant performance counters.

作为一个简化可以仅提取用于创建和存储的数据结构,并嵌入代码到一个控制台应用程序。运行模拟载荷和检查PERF柜台那里。您可以改变的事情,衡量内存消耗和垃圾回收的影响。这样做将隔离所要测量的影响。

As a simplification you could extract just the code that creates and stores data structures, and embed that into a console application. Run a simulated load and check the perf counters there. You can vary things and measure the impact on memory consumption and garbage collection. Doing this would isolate the effects you want to measure.

如果你想,哎呀,这听起来像一个大量的工作,那么你最好只是购买更多的内存。

If you're thinking, "gee, that sounds like a lot of work," then you are better off just buying more memory.

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

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