java_performance_the_definitive_guide.pdf

(9336 KB) Pobierz
Java Performance:
The Definitive Guide
Scott Oaks
Java Performance: The Definitive Guide
by Scott Oaks
Copyright © 2014 Scott Oaks. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or
corporate@oreilly.com.
Editor:
Meghan Blanchette
Production Editor:
Kristen Brown
Copyeditor:
Becca Freed
Proofreader:
Charles Roumeliotis
April 2014:
First Edition
Indexer:
Judith McConville
Cover Designer:
Karen Montgomery
Interior Designer:
David Futato
Illustrator:
Rebecca Demarest
Revision History for the First Edition:
2014-04-09:
2014-12-19:
First release
Second release
See
http://oreilly.com/catalog/errata.csp?isbn=9781449358457
for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly
Media, Inc.
Java Performance: The Definitive Guide,
the image of saiga antelopes, and related trade dress are
trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark
claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume no
responsibility for errors or omissions, or for damages resulting from the use of the information contained
herein.
ISBN: 978-1-449-35845-7
[LSI]
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
A Brief Outline
Platforms and Conventions
JVM Tuning Flags
The Complete Performance Story
Write Better Algorithms
Write Less Code
Oh Go Ahead, Prematurely Optimize
Look Elsewhere: The Database Is Always the Bottleneck
Optimize for the Common Case
Summary
Test a Real Application
Microbenchmarks
Macrobenchmarks
Mesobenchmarks
Common Code Examples
Understand Throughput, Batching, and Response Time
Elapsed Time (Batch) Measurements
Throughput Measurements
Response Time Tests
Understand Variability
Test Early, Test Often
Summary
Operating System Tools and Analysis
2
2
4
5
5
6
7
8
9
10
2. An Approach to Performance Testing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
11
11
16
18
20
24
24
25
26
29
33
36
37
iii
3. A Java Performance Toolbox. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Zgłoś jeśli naruszono regulamin