cse 341 programming languages performance patterns, macros

4
CSE 341 Programming Languages Performance Patterns, Macros Zach Tatlock Spring 2014

Upload: jacqui

Post on 23-Feb-2016

47 views

Category:

Documents


0 download

DESCRIPTION

CSE 341 Programming Languages Performance Patterns, Macros. Zach Tatlock Spring 2014. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CSE 341  Programming Languages Performance Patterns, Macros

CSE 341 Programming

Languages

Performance Patterns, Macros

Zach TatlockSpring 2014

Page 2: CSE 341  Programming Languages Performance Patterns, Macros

When I was a novice programmer, I spent many hours trying to "speed up" my code. One day, after many agonizing attempts at this feat, my mentor approached and asked how things were going. Upon hearing of my troubles, he imparted this sage wisdom:

"The CPU," he said, "runs at a certain speed. It can execute a fixed number of instructions per second, and no more. There is a finite limit to how many instructions per second it can execute.”

"So there is no way, really, to make code go faster, because there is no way to make instructions execute faster. There is only such a thing as making the machine do less."

He paused for emphasis.

"To go fast," he said slowly, "do less."

Page 3: CSE 341  Programming Languages Performance Patterns, Macros

Optimization

The 1st rule of optimization:Don’t do it.

The 2nd rule of optimization(experts only):

Don’t do it… yet.

Page 4: CSE 341  Programming Languages Performance Patterns, Macros

OptimizationSeriously, only optimize with profile in hand.

Otherwise, two very nasty consequences:1. time wasted- life is short!2. code unnecessarily complex- need more beauty in the world

YOLO