tune部分段落翻译

大部分能看明白,表达不够明确或者相当错误,还请各位达人帮忙纠错

Chapter 1. 介绍
The trouble with doing something right the first time is that nobody appreciates how difficult it was.
--Fortune

第一次做事情遇到麻烦是因为没有人理解这事儿有多困难。

There is a general perception that Java programs are slow. Part of this perception is pure assumption: many people assume that if a program is not compiled, it must be slow. Part of this perception is based in reality: many erly applets and applications were slow, because of nonoptimal coding, initially unoptimized Java Virtual Machines(VMs), and the overhead of the language.

通常认为Java程序运行非常慢。这种理解是纯粹的假设:许多人假定如果一个程序没有被编译,它一定很慢。而这个理解又来自于现实:很多早期的applets和applications运行很慢,因为并非最佳的编码,没有优化的Java虚拟机,和间接的语言。

In earlier versions of Java, you had to struggle hard and compromise a lot to make a Java application run quickly. More recently, there have been fewer reasons why an application should be slow. The VM technology and Java development tools have progressed to the point where a Java application (or applet, servlet, etc.) is not particularly handicapped. With good designs and by following good coding practices and avoiding bottlenecks, applications usually run fast enough. However, the truth is that the first (and even several subsequent) versions of a program written in any language are often slower than expected, and the reasons for this lack of performance are not always clear to the developer.

早期版本的Java,程序员们不得不努力地并做出很多妥协让Java application快速运行。最近,只有很少的原因使程序运行变慢。虚拟机技术和Java开发工具的发展使得Java程序并不存在显著的缺陷。通过良好的设计并遵循良好的编码规范并避免瓶颈的出现,程序通常运行得足够快。然而,事实上第一个(甚至之后的几个)用任何语言说编写的程序的运行通常都比预期的要缓慢,导致缺乏性能的原因并不是每个开发人员都清楚。

This book shows you why a particular Java application might be running slower than expected, and suggests ways to avoid or overcome these pitfalls and improve the performance of your application. In this book I've gathered several years of tuning experiences in one place. I hope you will find it useful in making your Java application, applet, servlet, and component run as fast as you need.

本书说明了为什么某个特定的Java应用程序可能运行得比预期的要慢,并提出了一些避免或者克服这些缺陷并提升应用性能的方法。本书中,我已经在一个地方搜集了数年的调整经验。我希望这对使你的Java应用程序,applet, servlet和组件运行更快有帮助。

Throughout the book I use the generic words "application" and "program" to cover Java applications, applets, servlets, beans, libraries, and really any use of Java code. Where a technique can be applied only to some subset of these various types of Java programs, I say so. Otherwise, the technique applies across all types of Java programs.

本书所有内容,我使用了一般性的词组"application"和"program"来代替Java应用程序,applets, servlets, beans, libbraries, 和所有实际的任何Java代码的应用。这个技术可应用到Java程序的一些子集中。另外,该技术适用于所有类型的Java程序。

1.1 Why Is It Slow?
This question is always asked as soon as the first tests are timed:"Where is the time going? I did not expect it to take this long." Well, the short answer is that it's slow because it has not been performance-tuned. In the same way the first version of the code is likely to have bugs that need fixing, it is also rarely as fast as it can be. Fortunately, performance tuning is usually easier than debugging. When debugging, you have to fix bugs throughtout the code; in performance tuning, you can focus your effort on the few parts of the application that are the bottlenecks.

它为什么这么慢?这个问题经常在第一次测试后就被问及:“这些时间在干吗?我并不希望它花这么长时间。” 好,简短的回答是它这么慢是因为它并没有被调整性能。即便这个代码的第一个版本可能有没有修复的bugs,它也可以以罕见的速度运行。幸运地是,性能调整通常比调试简单。调试时,你不得不去修复代码中所有的bugs;而在性能调整里,你只要集中注意,关注应用程序的少数几个方面,而这少数的方面往往就是瓶颈。

The longer answer? Well, it's true that there is overhead in the Java runtime system, mainly due to its virtual machine layer that abstracts Java away from the underlying hardware. It's also true that there is overhead from Java's dynamic nature. These overheads can cause a Java application to run slower than an equivalent application written in a lower-level language (just as a C program is generally slower than the equivalent program written in assembler). Java's advantages-namely, its platform-independence, memory management, powerful exception checking, built-in multithreading, dynamic resource loading, and security checks-add costs in terms of an interpreter,  garbage collector, thread monitors, repeated disk and network accessing, and extra runtime checks.

详细点儿的回答?那么,是不是真的有一套顶层的Java运行系统,主要由于它的虚拟机层将Java从底层硬件中抽象出来。它也确实间接地来自于Java的动态性。这些间接性导致Java应用程序比相对应地使用底层语言(比如C语言通常要比相对应汇编程序运行地慢)写的应用程序要运行地更慢。Java地优势,即平台无关性,内存管理,强大地异常检查,内建的多线程,动态资源加载,解释期间的安全检查的成本,垃圾收集,线程监视器,重复硬盘和网络访问,以及额外的运行时检查。

你可能感兴趣的:(java,虚拟机,servlet,网络应用,performance)