for (int x = 0; x < 60; x++)//x是压测多少秒
{ for (int j = 0; j < 100; j++)//j是并发数 {Task.Run(async () =>
{//for (int i = 0; ; i++)
for (int i = 0; i < 100; i++)//i是每个并发下执行多少次如果压测行为是起task的每秒钟的并发就是i*j { { DateTime tt1 = DateTime.Now; Task.Run(() => { //压测行为});
double time = (DateTime.Now - tt1).TotalMilliseconds; if (time < 1000) { await Task.Delay((int)(1000 - time)); } } } }); } System.Threading.Thread.Sleep(1000); break; } posted on 2016-11-26 23:24 阅读( ...) 评论( ...)