C++ Footprint and Performance
Optimization
Copyright
About the Authors
Acknowledgments
Tell Us What You Think!
Introduction: Why Optimize?
Aim of This Book
Who This Book Is For
The Structure of This Book
Part I: Everything But the Code
Chapter 1. Optimizing: What Is It All
About?
Performance
Footprint
Summary
Chapter 2. Creating a New System
System Requirements
System Design Issues
The Development Process
Data Processing Methods
Summary
Chapter 3. Modifying an Existing System
Identifying What to Modify
Beginning Your Optimization
Analyzing Target Areas
Performing the Optimizations
Summary
Part II: Getting Our Hands Dirty
Chapter 4. Tools and Languages
Tools You Cannot Do Without
Optimizing with Help from the Compiler
The Language for the Job
Summary
Chapter 5. Measuring Time and
Complexity
The Marriage of Theory and Practice
System Influences
Summary
Chapter 6. The Standard C/C++ Variables
Variable Base Types
Grouping Base Types
Summary
Chapter 7. Basic Programming Statements
Selectors
Loops
Summary
Chapter 8. Functions
Invoking Functions
Passing Data to Functions
Early Returns
Functions as Class Methods
Summary
Chapter 9. Efficient Memory Management
Memory Fragmentation
Memory Management
Resizable Data Structures
Summary
Chapter 10. Blocks of Data
Comparing Blocks of Data
The Theory of Sorting Data
Sorting Techniques
Summary
Chapter 11. Storage Structures
Arrays
Linked Lists
Hash Tables
Binary Trees
Red/Black Trees
Summary
Chapter 12. Optimizing IO
Efficient Screen Output
Efficient Binary File IO
Efficient Text File IO
Summary
Note that the way in which data is placed
in tmp and shifted upwards in the
direction of the most significant byte,
makes it ideal for big-endian
implementations. If, however, you would
like to receive the bytes of the device in a
little-endian order, some changes need to
be made as shown in Listing 15.14.
Listing 15.14 Efficient Hardware
Address Access (Little-Endian)
unsigned char buffer[1024];
for (int i = 0; i < buflen; i+= 4)
{
register long tmp;
tmp = (*HARDWAREMAPPEDREGI
tmp |= (*HARDWAREMAPPEDREGI
tmp |= (*HARDWAREMAPPEDREGI
tmp |= (*HARDWAREMAPPEDREGI
buffer[i]
= tmp
}
CONTENTS