Mono上的垃圾收集最坏情况表现

时间:2021-11-30 05:34:44

Hi i want to find out the longest time needed to call a method or to create an object.

您好我想找出调用方法或创建对象所需的最长时间。

I thought of something like calling GC.Collect() before creating the object or during the method or calling some destructors.

我想到了在创建对象之前或在方法或调用一些析构函数之前调用GC.Collect()之类的东西。

Has anyone some hints or ideas for finding out some (or the) worst case scenarios?

找到一些(或最坏的)最坏情况,是否有任何提示或想法?

best regards

1 个解决方案

#1


1  

See this thread. Put the answer code in a loop and record lowest & highest time that come in. But that may not be actually that intersting. Here is better performance meassaring:

看到这个帖子。将答案代码放在一个循环中并记录进入的最低和最高时间。但这实际上可能不是那个有用的。这是更好的性能测量:

Run the code in you actual application to get a feel of a real life scenario

在您的实际应用程序中运行代码,以了解真实生活场景

or

Run a test on say 100000 calls to whatever method you want to test then you can take an average of the call times which should give you a better indication if your method is slow or not

对你想要测试的任何方法进行100000次调用运行测试然后你可以平均一次调用时间,这可以让你更好地指出你的方法是否很慢

#1


1  

See this thread. Put the answer code in a loop and record lowest & highest time that come in. But that may not be actually that intersting. Here is better performance meassaring:

看到这个帖子。将答案代码放在一个循环中并记录进入的最低和最高时间。但这实际上可能不是那个有用的。这是更好的性能测量:

Run the code in you actual application to get a feel of a real life scenario

在您的实际应用程序中运行代码,以了解真实生活场景

or

Run a test on say 100000 calls to whatever method you want to test then you can take an average of the call times which should give you a better indication if your method is slow or not

对你想要测试的任何方法进行100000次调用运行测试然后你可以平均一次调用时间,这可以让你更好地指出你的方法是否很慢