应用程序减速

时间:2011-07-12 00:17:21

标签: c# asp.net httphandler

我正在尝试使用apache bench来对我的应用程序进行基准测试,并且我得到了“有趣”的结果

从我的应用程序和apache工作台的输出中查看日志似乎存在很大的差异。我将其归结为网络延迟,但在对“localhost”进行基准测试时仍存在差异。

如何确定延迟的位置,因为它似乎不是基于网络而不是基于我的代码。

AB报告

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.6      0       2
Processing:   849 1353 511.1   1247    3233
Waiting:      848 1353 511.1   1247    3233
Total:        850 1353 511.4   1247    3235

Percentage of the requests served within a certain time (ms)
  50%   1247
  66%   1329
  75%   1497
  80%   1595
  90%   1890
  95%   3235
  98%   3235
  99%   3235
 100%   3235 (longest request)

应用程序日志

0.457508658971436
0.487119069125137
0.64489275544097
0.308814075251248
0.347146275286174
0.413624988232478
0.346384754750842
0.440318102805972
0.383319550604894
0.501201249649599
0.546330090455061
0.324228916712541
0.503295781085244
0.258641210789654
0.419751448936304
0.344909658677117
0.368373660208557
0.391326015130321
0.408486124472911
0.432033417312903
0.841326557573717
0.380724921354457
0.982096568223106
0.988279723010904
0.477995521167366
0.553187274907863
0.604180103806168
0.605961767889521
0.5603846238645
0.469985557007126
0.602743853678869
0.613931136285929
0.518576586533195
0.589374548765836
0.541912501430476
0.56989243172475
0.516491854075027
0.409568911484087
0.245887841603729
3.22576074186659

我的代码

    public void ProcessRequest(HttpContext context)
    {
        var fullTimer = new utilities.HiPerfTimer();
        fullTimer.Start();
        // CUSTOM CODE WENT HERE
        fullTimer.Stop();
        System.Diagnostics.Debug.WriteLine(fullTimer.Duration);
    }

1 个答案:

答案 0 :(得分:0)

我肯定会看到像探查器这样的东西。我已经使用Redgate's ANTs performance profiler来测试一些运行缓慢的我的代码。尽管我认为代码非常简单,但它向我展示了一条线占据了48%的执行时间。

还有很多其他性能分析器,您可以使用免费试用期来立即指示导致减速的原因。