秒表计时不同,为什么? [英] Stopwatch different timing why?

查看:180
本文介绍了秒表计时不同,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用秒表启动和停止,以找出如何以往任何时候都当我刷新页面,以便使用相同的参数,数据的所有,但第二个和所有做另一个测试Web服务的过程的时间其他测试带回不同的结果。但是,当我重​​新启动IIS服务器再次显示了初步成果。

I am using a stopwatch start and stop in order to find out the time of process of a web service how ever when I refresh the page in order to do another test using the same parameters, data an all but the second and all the other test bring back different results. But when I restart the IIS server it again shows the initial result.

所以我的问题是为什么会收到一个不同的结果及时在第一时间?

So my question is why do I receive a different result in time the first time?

当我在C#编写的Web服务的方式。

By the way I wrote the web service in C#.

推荐答案

要了解为什么它要慢得多的第一次,考虑一下有发生第一次:

To understand why it's much slower the first time, consider what has to happen the first time:


  1. 组件必须从磁盘加载。

  2. 的code会被即时编译,这意味着它必须从IL翻译成机器code。

  3. 的页面(.cshtml /的.aspx)必须被解析。一旦解析,他们重新编译presentation存储在内存中,并立即在随后的请求。

一般来说,没有有发生加载页面的第二次。有可能这种情况发生在第一时间,然后被缓存无数其他事情。这就是后来的刷新通常会快很多。

Generally speaking, none of that has to happen the second time you load the page. There are potentially countless other things that happen the first time and are then cached. This is why subsequent refreshes will usually be much faster.

这篇关于秒表计时不同,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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