From the Frontiers of Research to the Heart of the Enterprise
O'Reilly Open Source Convention
Sheraton San Diego Hotel and Marina
July 22-26, 2002 -- San Diego, CA
Optimize Your Perl Code
Robert Spier, Google
Date: Tuesday, July 23
Time: 8:45am - 12:15pm
Location: Grande Ballroom B
This tutorial is an introduction to optimizating perl applications. It's important knowledge for anyone writing time-sensitive applications, from a CGI script to a large application.
It covers the following four major components:
- A brief introduction to complexity theory
Just enough complexity theory to have a basic language to talk about runtimes of functions. O(1), O(n), O(n^2), etc. Complexity of common perl idioms like map, sort, nested loops, etc. Why is some code slow? (And it's not perl's fault!)
- Real world / real code examples and how to make them faster
Examples of O(n^2) or worse functions and how they can be improved by an order of magnitude by rewriting the algorithm,
and possibly changing the data structures used to store things. Memoization/Caching/Persistency/Precomputing.
- Some simple Benchmarking
Devel::DProf and Benchmark.pm can help to isolate problem spots in your code. Learn how to properly interpret data and how to pick the "important" pieces.
- Is it worth it?
Not all time spent optimizing the code is worth it. There are tradeoffs of time, readability, speed. Discuss development strategies, pre-optimization, and over-optimization. O(n) can be faster than O(1) for small n.
oreilly.com Home |
O'Reilly Bookstores |
How to Order |
About O'Reilly |
Affiliated Companies |
© 2001, O'Reilly Media, Inc.