为什么第二次运行exe文件会快一点?

whatapig 2001-09-11 02:48:01
理论上是这样的,我没有实际试过。问题是:
1.是不是真的是这样,有没有数据表明会快多少。官方的最好。
2.为什么会快。理论上是中间语言被解释成了机器指令,那么这个指令信息保存在什么地方?
3.mscoree.dll是不是就干这个勾当的?
...全文
181 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
karma 2001-09-13
  • 打赏
  • 举报
回复
JIT in the .Net will compile the IL to native code, i.e., machine code. So at the end, the machine code will be executed. The native code is kept in memory and will be lost if you shut down the machine. Next time you start the machine and run the code again, it will be re-compiled. Of course, you can always pre-compile the IL code into native code. Actually, there are three types of JITers:

Econo-JIT
Quickly generates fairly low quality native code (fast to generate, almost
no optimization) - caches generated code in memory - throws out generated
code to make room for new code as needed - may result in recompilation of
the same function

Regular JIT
Generates more optimized native code than the econo-JIT - currently keeps
code in memory for the life of the app domain - may cache and discard code
like the econoJIT in later versions of the runtime

PreJIT
Saves JITted code to disk so application doesn't have to re-compile when
loaded - can also take a little longer to optimize and generate more
optimized native code

dingyin 2001-09-13
  • 打赏
  • 举报
回复
问题是JIT以后,在运行是不是直接执行机器代码
whatapig 2001-09-12
  • 打赏
  • 举报
回复
在JIT编译完了的本地代码,是以什么形式存放的?在我看来,始终只有高层的编译器生成的中间代码。从用户角度来看,"执行"也是这段代码。
能介绍以下对象池的概念么?
另外,是不是Transmeta公司搞的那种技术也类似于此?
niwalker 2001-09-11
  • 打赏
  • 举报
回复
正确,我用ASP.NET作了一个应用,可以充分证明这一点。
szxzwang 2001-09-11
  • 打赏
  • 举报
回复
上面的老兄的第2条我同意。当程序第二次运行时,它就不必再次JIT编译了。所以会快。
Optimus 2001-09-11
  • 打赏
  • 举报
回复
1,好像没有官方的报道,其实这与机器的性能有直接关系吧:〉
2,实际上是,首先在编译的时候,源代码会被编译成中间代码,中间代码是可以通过一个叫做MetaData的数据包自解释的,然后执行前要JIT编译成本地代码。第一次调用都要经过这个过程,但是如果下一次调用同一段代码,就不必再次JIT编译了。所以会快。
据一些书上所说,.NET具有对象池的概念,可能是它起了作用。
3。不太清楚。(不好意思)
ripper 2001-09-11
  • 打赏
  • 举报
回复
大概编译过的il会被缓存起来呗,咱也没有试过,可以参考一下ms的关于il和clr的文档
whatapig 2001-09-11
  • 打赏
  • 举报
回复
push,没人回答么?

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧