Tag: 压力测试

C#压力测试 – 模拟对给定共享资源的多次访问

如何在ac#unit test中模拟/压力测试大约100个访问给定共享资源(例如数据库)的用户?

为什么SHA1.ComputeHash在很multithreading的高负载下失败?

我看到我维护的一些代码存在问题。 下面的代码有一个private static SHA1成员(这是一个IDisposable但因为它是static ,它永远不应该最终确定)。 但是,在压力下,此代码会抛出一个exception,表明它已被关闭: Caught exception. Safe handle has been closed” Stack trace: Call stack where exception was thrown at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success) at System.Security.Cryptography.Utils.HashData(SafeHashHandle hHash, Byte[] data, Int32 cbData, Int32 ibStart, Int32 cbSize) at System.Security.Cryptography.Utils.HashData(SafeHashHandle hHash, Byte[] data, Int32 ibStart, Int32 cbSize) at System.Security.Cryptography.HashAlgorithm.ComputeHash(Byte[] buffer) 有问题的代码是: internal class TokenCache { private static SHA1 […]