Performance and Code Tuning Overview CPSC 315 – Programming Studio Fall 2009.

Slides:



Advertisements
Similar presentations
Chapter 8 Technicalities: Functions, etc. Bjarne Stroustrup
Advertisements

Code Tuning Strategies and Techniques
Code Tuning Techniques CPSC 315 – Programming Studio Fall 2008 Most examples from Code Complete 2.
When and How to Improve Code Performance? Ivaylo Bratoev Telerik Corporation
Code Tuning Strategies and Techniques CS524 – Software Engineering Azusa Pacific University Dr. Sheldon X. Liang Mike Rickman.
Software & Services Group, Developer Products Division Copyright© 2010, Intel Corporation. All rights reserved. *Other brands and names are the property.
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
Analysis of Algorithms CS Data Structures Section 2.6.
Chapter 1 An Overview of Computers and Programming Languages.
1 Program Design Language (PDL) Slides by: Noppadon Kamolvilassatian Source: Code Complete by Steve McConnell, Chapter 4.
TU/e Processor Design 5Z032 1 Processor Design 5Z032 The role of Performance Henk Corporaal Eindhoven University of Technology 2009.
Algorithms Today we will look at: what we mean by efficiency in programs why efficiency matters what causes programs to be inefficient? will one algorithm.
CMPT 225 Sorting Algorithms Algorithm Analysis: Big O Notation.
Copyright © 2003, SAS Institute Inc. All rights reserved. Where's Waldo Uncovering Hard-to-Find Application Killers Claire Cates SAS Institute, Inc
Online Performance Auditing Using Hot Optimizations Without Getting Burned Jeremy Lau (UCSD, IBM) Matthew Arnold (IBM) Michael Hind (IBM) Brad Calder (UCSD)
API Design CPSC 315 – Programming Studio Fall 2008 Follows Kernighan and Pike, The Practice of Programming and Joshua Bloch’s Library-Centric Software.
Introduction to Analysis of Algorithms
1 Lecture 6 Performance Measurement and Improvement.
Introduction to Primitives. Overview Today we will discuss: –The eight primitive types, especially int and double –Declaring the types of variables –Operations.
Chapter 4 Assessing and Understanding Performance
27-Jun-15 Profiling code, Timing Methods. Optimization Optimization is the process of making a program as fast (or as small) as possible Here’s what the.
30-Jun-15 Profiling. Optimization Optimization is the process of making a program as fast (or as small) as possible Here’s what the experts say about.
Amdahl's Law.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
1 Chapter 4. 2 Measure, Report, and Summarize Make intelligent choices See through the marketing hype Key to understanding underlying organizational motivation.
Cmpt-225 Simulation. Application: Simulation Simulation  A technique for modeling the behavior of both natural and human-made systems  Goal Generate.
Code-Tuning By Jacob Shattuck. Code size/complexity vs computation resource utilization A classic example: Bubblesort A classic example: Bubblesort const.
Array.
Topic #10: Optimization EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
Introduction and Overview Questions answered in this lecture: What is an operating system? How have operating systems evolved? Why study operating systems?
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Marie desJardins University of Maryland, Baltimore County.
10/19/2015Erkay Savas1 Performance Computer Architecture – CS401 Erkay Savas Sabanci University.
Analysis of algorithms Analysis of algorithms is the branch of computer science that studies the performance of algorithms, especially their run time.
Chapter 25: Code-Tuning Strategies. Chapter 25  Code tuning is one way of improving a program’s performance, You can often find other ways to improve.
Introduction To PROLOG World view of imperative languages. World view of relational languages. A PROLOG program. Running a PROLOG program. A PROLOG.
Performance.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 12/6/2006 Lecture 24 – Profilers.
CS 3500 L Performance l Code Complete 2 – Chapters 25/26 and Chapter 7 of K&P l Compare today to 44 years ago – The Burroughs B1700 – circa 1974.
Software Development. Software Development Loop Design  Programmers need a solid foundation before they start coding anything  Understand the task.
CPSC 873 John D. McGregor Session 9 Testing Vocabulary.
Compiler Optimizations ECE 454 Computer Systems Programming Topics: The Role of the Compiler Common Compiler (Automatic) Code Optimizations Cristiana Amza.
CPSC 871 John D. McGregor Module 8 Session 1 Testing.
September 10 Performance Read 3.1 through 3.4 for Wednesday Only 3 classes before 1 st Exam!
Computer Organization Instruction Set Architecture (ISA) Instruction Set Architecture (ISA), or simply Architecture, of a computer is the.
The Process From bare bones to finished product. The Steps Programming Debugging Performance Tuning Optimization.
CS 150: Analysis of Algorithms. Goals for this Unit Begin a focus on data structures and algorithms Understand the nature of the performance of algorithms.
Searching Topics Sequential Search Binary Search.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Copyright 2014 – Noah Mendelsohn Performance Analysis Tools Noah Mendelsohn Tufts University Web:
Observing the Current System Benefits Can see how the system actually works in practice Can ask people to explain what they are doing – to gain a clear.
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
What is it and why do we need it? Chris Ward CS147 10/16/2008.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
CPSC 372 John D. McGregor Module 8 Session 1 Testing.
CSE 340 Computer Architecture Summer 2016 Understanding Performance.
What Do Computers Do? A computer system is
John D. McGregor Session 9 Testing Vocabulary
Algorithmic complexity: Speed of algorithms
Lecture 3 of Computer Science II
John D. McGregor Session 9 Testing Vocabulary
Array.
Performance and Code Tuning
John D. McGregor Session 9 Testing Vocabulary
Winter 2018 CISC101 12/2/2018 CISC101 Reminders
Algorithmic complexity: Speed of algorithms
Asst. Dr.Surasak Mungsing
CSE 373 Data Structures and Algorithms
Algorithmic complexity: Speed of algorithms
Performance and Code Tuning Overview
Presentation transcript:

Performance and Code Tuning Overview CPSC 315 – Programming Studio Fall 2009

Is Performance Important? Performance tends to improve with time HW Improvements (might not last?) Other things can be more important Accuracy Robustness Code Readability Worrying about it can cause problems “More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason – including blind stupidity.” – William A. Wulf

Performance Increases without Code Tuning Lower your Standards/Requirements Asking for more than is needed leads to trouble Example: Return in 1 second Always? On Average? 99% of the time?

Performance Increases without Code Tuning Lower your Standards/Requirements High Level Design The overall program structure can play a huge role

Performance Increases without Code Tuning Lower your Standards/Requirements High Level Design Class/Routine Design Algorithms used have real differences Can have largest effect, especially asymptotically

Performance Increases without Code Tuning Lower your Standards/Requirements High Level Design Class/Routine Design Interactions with Operating System Hidden OS calls within libraries – their performance affects overall code

Performance Increases without Code Tuning Lower your Standards/Requirements High Level Design Class/Routine Design Interactions with Operating System Upgrade Hardware Straightforward, if possible…

Performance Increases without Code Tuning Lower your Standards/Requirements High Level Design Class/Routine Design Interactions with Operating System Upgrade Hardware Compiler Optimizations “Automatic” optimization, Getting better and better, though not perfect Different compilers work better/worse

Code Profiling Determine where code is spending time No sense in optimizing where no time is spent Provide measurement basis Determine whether “improvement” really improved anything Need to take precise measurements

Profiling Techniques Profiler – compile with profiling options, and run through profiler Gets list of functions/routines, and amount of time spent in each Use system timer Less ideal Might need test harness for functions Use system-supported real time Only slightly better than wristwatch… Graph results for understanding Multiple profile results: see how profile changes for different input types

What Is Tuning? Making small-scale adjustments to correct code in order to improve performance After code is written and working Affects only small-scale: a few lines, or at most one routine Examples: adjusting details of loops, expressions Code tuning can sometimes improve code efficiency tremendously

What Tuning is Not Reducing lines of code Not an indicator of efficient code A guess at what might improve things Know what you’re trying, and measure results Optimizing as you go Wait until finished, then go back to improve Optimizing while programming often a waste A “first choice” for improvement Worry about other details/design first

Common Inefficiencies Unnecessary I/O operations File access especially slow Paging/Memory issues Can vary by system System Calls Interpreted Languages C/C++/VB tend to be “best” Java about 1.5 times slower PHP/Python about 100 times slower

Operation Costs Different operations take different times Integer division longer than other ops Transcendental functions (sin, sqrt, etc.) even longer Knowing this can help when tuning Vary by language In C++, private routine calls take about twice the time of an integer op, and in Java about half the time.

Remember Code readability/maintainability/etc. is usually more important than efficiency Always start with well-written code, and only tune at the end Measure!