及时问题 [英] Just In Time Question

查看:58
本文介绍了及时问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#的新手,到目前为止,我对它背后的语言和

设计非常满意。我唯一真正关心的是性能。


我想问一个关于你在Visual

studio中构建的程序是如何处理的问题。


构建完成后,你看起来像普通的win32 exe。并且

该代码的最少部分必须是因为它运行。现在我已经读过了

,JIT编译器会编译程序中需要编译以启动应用程序的
部分。并且它只需要编译其余部分。


现在,假设我到目前为止,我的问题是:


这个编译代码在哪里?它是否被编译到您从Visual Studio构建的

原始exe文件中,以便编译的

代码始终存在并且JIT再也不需要了一旦它b / b $ b $全部编译完毕?或者它是否被放在.Net

Framework Land的一侧,当机器

重新启动时需要重新编译?


另外,一旦编译程序就像win32程序一样快?


感谢您的帮助。

I''m new to C# and so far I''m pretty happy with the language and the
design behind it. My only real concern is about performance.

I wanted to ask a question about how a program you build in Visual
studio gets handled.

After it is built you have what looks like an normal win32 exe. And at
least part of that code must be because it runs. Now I''ve read that
what happens is the JIT compiler compiles the portion of the program
that needs to be compiled to start the app. And that it only compiles
the rest as it is needed.

Now, assuming I''m right so far, my question is this:

Where is this compiled code going? Is it getting compiled into the
original exe file you built from Visual Studio so that the compiled
code is there for all time and JIT won''t be needed ever again once it
is all compiled? Or is it being kept off on the side somewhere in .Net
Framework Land and will need to be recompiled when the machine
reboots?

Also, once the program is compiled is it as fast as a win32 program?

Thanks for any help.

推荐答案

Phill< wa ******** @ yahoo.com>写道:
Phill <wa********@yahoo.com> wrote:
我是C#的新手,到目前为止,我对它背后的语言和
设计感到非常满意。我唯一真正关心的是性能。

我想问一个关于你在Visual
工作室中构建的程序是如何处理的问题。

构建完成后你看起来像一个普通的win32 exe。并且至少部分代码必须是因为它运行。现在我已经读过了这样的事情:JIT编译器会编译需要编译以启动应用程序的程序部分。并且它只会在需要时编译其余部分。

现在,假设我到目前为止,我的问题是:

这个编译的代码会怎样它是否被编译到您从Visual Studio构建的原始exe文件中,以便编译后的代码始终存在,并且一旦它全部完成就不再需要JIT
编译?或者它是否在.Net
Framework Land的某个地方被关闭,当机器重新启动时需要重新编译?


这基本上是在记忆中,有效。 (它可能会被写入磁盘

临时文件 - 我不确定。)JIT编译器下次重新编译它b / b
。您可以使用ngen.exe来预JIT。它 - 虽然我相信

ngen不能像真实那样进行优化。 JIT。

另外,一旦程序编译得和win32程序一样快?
I''m new to C# and so far I''m pretty happy with the language and the
design behind it. My only real concern is about performance.

I wanted to ask a question about how a program you build in Visual
studio gets handled.

After it is built you have what looks like an normal win32 exe. And at
least part of that code must be because it runs. Now I''ve read that
what happens is the JIT compiler compiles the portion of the program
that needs to be compiled to start the app. And that it only compiles
the rest as it is needed.

Now, assuming I''m right so far, my question is this:

Where is this compiled code going? Is it getting compiled into the
original exe file you built from Visual Studio so that the compiled
code is there for all time and JIT won''t be needed ever again once it
is all compiled? Or is it being kept off on the side somewhere in .Net
Framework Land and will need to be recompiled when the machine
reboots?
It''s basically in memory, effectively. (It may get written out to disk
on a temporary file - I''m not sure.) The JIT compiler recompiles it
next time. You can use ngen.exe to "pre-JIT" it - although I believe
ngen can''t optimise as heavily as the "real" JIT.
Also, once the program is compiled is it as fast as a win32 program?




粗略。也许有点慢。如果你非常不走运,那么你最终会做一些比一个经过充分优化的时间要好得多的东西,比如
C / C ++,并做到这一点在循环中,很多次。然而,对于大多数应用来说,它不会产生那么大的差异。


-

Jon Skeet - < ; sk *** @ pobox.com>
http://www.pobox .com / ~siget

如果回复该组,请不要给我发邮件



Roughly. Maybe a bit slower. If you''re very unlucky, you''ll end up
doing something which is much slower than a well-optimised bit of
C/C++, and do it in a loop, lots of times. For most apps, however, it
doesn''t make that much difference.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


>它基本上是在记忆中,有效地。 (它可能会在临时文件上写到磁盘
> It''s basically in memory, effectively. (It may get written out to disk
- 我不确定。)JIT编译器下次重新编译它。您可以使用ngen.exe来预JIT。它 - 虽然我相信
ngen不能像真实那样进行优化。 JIT。
on a temporary file - I''m not sure.) The JIT compiler recompiles it
next time. You can use ngen.exe to "pre-JIT" it - although I believe
ngen can''t optimise as heavily as the "real" JIT.
此外,一旦编译程序,它是否与win32程序一样快?
Also, once the program is compiled is it as fast as a win32 program?



粗略。也许有点慢。如果你非常不走运,那么你最终会做一些比C / C ++优化得更慢的东西,而且很多时候都是循环的。然而,对于大多数应用来说,它并没有那么大的差别。



Roughly. Maybe a bit slower. If you''re very unlucky, you''ll end up
doing something which is much slower than a well-optimised bit of
C/C++, and do it in a loop, lots of times. For most apps, however, it
doesn''t make that much difference.




好​​的,那么为什么JIT会这样工作呢?他们为什么认为一遍又一遍地编译程序是个好主意?为什么没有

JIT只做一次?这对我来说没有多大意义。



OK, so why does the JIT work that way? Why did they think it was a
good idea to keep compiling programs over and over again? Why not have
the JIT only do it once? That doesn''t make much sense to me.


Phill< wa ******** @ yahoo.com>写道:
Phill <wa********@yahoo.com> wrote:
它基本上是在记忆中,有效。 (它可能会在临时文件上写到磁盘上 - 我不确定。)JIT编译器下次重新编译它。您可以使用ngen.exe来预JIT。它 - 虽然我相信
ngen不能像真实那样进行优化。 JIT。
It''s basically in memory, effectively. (It may get written out to disk
on a temporary file - I''m not sure.) The JIT compiler recompiles it
next time. You can use ngen.exe to "pre-JIT" it - although I believe
ngen can''t optimise as heavily as the "real" JIT.
此外,一旦编译程序,它是否与win32程序一样快?
Also, once the program is compiled is it as fast as a win32 program?



粗略。也许有点慢。如果你非常不走运,那么你最终会做一些比C / C ++优化得更慢的东西,而且很多时候都是循环的。然而,对于大多数应用程序而言,它并没有那么大的差别。



Roughly. Maybe a bit slower. If you''re very unlucky, you''ll end up
doing something which is much slower than a well-optimised bit of
C/C++, and do it in a loop, lots of times. For most apps, however, it
doesn''t make that much difference.



好的,那么为什么JIT会这样工作呢?为什么他们认为一遍又一遍地编译程序是一个好主意?为什么不让JIT只做一次?这对我来说没有多大意义。



OK, so why does the JIT work that way? Why did they think it was a
good idea to keep compiling programs over and over again? Why not have
the JIT only do it once? That doesn''t make much sense to me.




嗯,这意味着:


1)你不要我需要能够写入磁盘才能运行

程序

2)你不需要进行复杂的检查以确保代码

你以前JIT的是你现在运行的相同代码

3)你可以根据(比如)CPU进行优化,这可能是不同的

下次运行代码时


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件



Well, it means that:

1) You don''t need to be able to write to the disk in order to run the
program
2) You don''t need to have complicated checks to make sure that the code
you JITted before is the same code you''re running now
3) You can make optimisations based on (say) CPU which may be different
next time you run the code

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于及时问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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