SlideShare une entreprise Scribd logo
1  sur  34
Code Tuning Techniques Most examples from Code Complete 2
Tuning Code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tuning Code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Logical Approaches: Stop Testing Once You Know the Answer ,[object Object],[object Object],[object Object],[object Object],[object Object]
Logical Approaches: Stop Testing Once You Know the Answer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Logical Approaches: Order Tests by Frequency ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Logical Approaches: Use Lookup Tables ,[object Object],[object Object],1 1 B A 1 C 2 2 3 2 0
Logical Approaches: Use Lookup Tables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1 1 B A 1 C 2 2 3 2 0
Logical Approaches: Use Lookup Tables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1 1 B A 1 C 2 2 3 2 0
Logical Approaches: Lazy Evaluation ,[object Object],[object Object],[object Object]
Tuning Loops: Unswitching ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tuning Loops: Jamming ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tuning Loops: Unrolling ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tuning Loops: Minimizing Interior Work ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tuning Loops: Sentinel Values ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tuning Loops: Busiest Loop on Inside ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tuning Loops: Strength Reduction ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Transforming Data: Integers Instead of Floats ,[object Object],[object Object],[object Object],[object Object]
Transforming Data: Fewer Array Dimensions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Transforming Data: Minimize Array Refs ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Transforming Data: Use Supplementary Indexes ,[object Object],[object Object]
Transforming Data: Use Caching ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tuning Expressions: Algebraic Identities and Strength Reduction ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tuning Expressions: Compile-Time Initialization ,[object Object],[object Object],[object Object],[object Object]
Tuning Expressions: Avoid System Calls ,[object Object],[object Object],[object Object],[object Object]
Tuning Expressions: Use Correct Types ,[object Object],[object Object]
Tuning Expressions: Precompute Results ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tuning Expressions: Eliminate Common Subexpressions ,[object Object],[object Object],[object Object],[object Object],[object Object]
Other Tuning: Inlining Routines ,[object Object],[object Object],[object Object],[object Object]
Other Tuning: Recoding in Low-Level Language ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Other Tuning: Buffer I/O ,[object Object],[object Object],[object Object]
Other Tuning: Handle Special Cases Separately ,[object Object],[object Object],[object Object],[object Object]
Other Tuning: Use Approximate Values ,[object Object],[object Object],[object Object]
Other Tuning: Recompute to Save Space ,[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Simulation-Run-Statistics
Simulation-Run-StatisticsSimulation-Run-Statistics
Simulation-Run-Statistics
sadiksha kafle
 

Tendances (20)

String Matching (Naive,Rabin-Karp,KMP)
String Matching (Naive,Rabin-Karp,KMP)String Matching (Naive,Rabin-Karp,KMP)
String Matching (Naive,Rabin-Karp,KMP)
 
Simulation & Modeling about Telephone System
Simulation & Modeling about Telephone SystemSimulation & Modeling about Telephone System
Simulation & Modeling about Telephone System
 
Formal methods 4 - Z notation
Formal methods   4 - Z notationFormal methods   4 - Z notation
Formal methods 4 - Z notation
 
C Programming
C ProgrammingC Programming
C Programming
 
System call
System callSystem call
System call
 
Design Assignment ( Recreation of IRCTC Booking System in Andriod Platform)
Design Assignment ( Recreation of IRCTC Booking System in Andriod Platform)Design Assignment ( Recreation of IRCTC Booking System in Andriod Platform)
Design Assignment ( Recreation of IRCTC Booking System in Andriod Platform)
 
CP Handout#4
CP Handout#4CP Handout#4
CP Handout#4
 
String matching algorithms(knuth morris-pratt)
String matching algorithms(knuth morris-pratt)String matching algorithms(knuth morris-pratt)
String matching algorithms(knuth morris-pratt)
 
Basic Block Scheduling
Basic Block SchedulingBasic Block Scheduling
Basic Block Scheduling
 
The solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinThe solution manual of programming in ansi by Robin
The solution manual of programming in ansi by Robin
 
Homework solutionsch9
Homework solutionsch9Homework solutionsch9
Homework solutionsch9
 
Z specification
Z specificationZ specification
Z specification
 
Chapter 1 : Balagurusamy_ Programming ANsI in C
Chapter 1  :  Balagurusamy_ Programming ANsI in C Chapter 1  :  Balagurusamy_ Programming ANsI in C
Chapter 1 : Balagurusamy_ Programming ANsI in C
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
types of loops and what is loop
types of loops and what is looptypes of loops and what is loop
types of loops and what is loop
 
Presentation on cyclic redundancy check (crc)
Presentation on cyclic redundancy check (crc)Presentation on cyclic redundancy check (crc)
Presentation on cyclic redundancy check (crc)
 
Simulation-Run-Statistics
Simulation-Run-StatisticsSimulation-Run-Statistics
Simulation-Run-Statistics
 
Automation Concepts
Automation ConceptsAutomation Concepts
Automation Concepts
 
Food order
Food orderFood order
Food order
 
Software testing Report
Software testing ReportSoftware testing Report
Software testing Report
 

En vedette

程序员发展漫谈
程序员发展漫谈程序员发展漫谈
程序员发展漫谈
Horky Chen
 

En vedette (20)

Code tuning techniques
Code tuning techniquesCode tuning techniques
Code tuning techniques
 
Optimization in Programming languages
Optimization in Programming languagesOptimization in Programming languages
Optimization in Programming languages
 
Code and memory optimization tricks
Code and memory optimization tricksCode and memory optimization tricks
Code and memory optimization tricks
 
代码大全(内训)
代码大全(内训)代码大全(内训)
代码大全(内训)
 
程序员实践之路
程序员实践之路程序员实践之路
程序员实践之路
 
高品質軟體的基本動作 101 + 102 for NUU
高品質軟體的基本動作 101 + 102 for NUU高品質軟體的基本動作 101 + 102 for NUU
高品質軟體的基本動作 101 + 102 for NUU
 
Design in construction
Design in constructionDesign in construction
Design in construction
 
Integration
IntegrationIntegration
Integration
 
Defencive programming
Defencive programmingDefencive programming
Defencive programming
 
A Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer TestingA Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer Testing
 
MOST_OpenFoundry_version control system_Git
MOST_OpenFoundry_version control system_GitMOST_OpenFoundry_version control system_Git
MOST_OpenFoundry_version control system_Git
 
程序员发展漫谈
程序员发展漫谈程序员发展漫谈
程序员发展漫谈
 
Java scriptcore brief introduction
Java scriptcore brief introductionJava scriptcore brief introduction
Java scriptcore brief introduction
 
Variables
VariablesVariables
Variables
 
Coding Style
Coding StyleCoding Style
Coding Style
 
Design in construction
Design in constructionDesign in construction
Design in construction
 
高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHU高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHU
 
Code Complete
Code CompleteCode Complete
Code Complete
 
Introduction to code optimization by dipankar
Introduction to code optimization by dipankarIntroduction to code optimization by dipankar
Introduction to code optimization by dipankar
 
The pseudocode
The pseudocodeThe pseudocode
The pseudocode
 

Similaire à Code Tuning

C programming session 02
C programming session 02C programming session 02
C programming session 02
Dushmanta Nath
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
PRADEEP
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6
Vince Vo
 

Similaire à Code Tuning (20)

Code Tuning
Code TuningCode Tuning
Code Tuning
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
 
Code optimization
Code optimization Code optimization
Code optimization
 
Code optimization
Code optimization Code optimization
Code optimization
 
VHDL Packages, Coding Styles for Arithmetic Operations and VHDL-200x Additions
VHDL Packages, Coding Styles for Arithmetic Operations and VHDL-200x AdditionsVHDL Packages, Coding Styles for Arithmetic Operations and VHDL-200x Additions
VHDL Packages, Coding Styles for Arithmetic Operations and VHDL-200x Additions
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
3.Loops_conditionals.pdf
3.Loops_conditionals.pdf3.Loops_conditionals.pdf
3.Loops_conditionals.pdf
 
ERTS UNIT 3.ppt
ERTS UNIT 3.pptERTS UNIT 3.ppt
ERTS UNIT 3.ppt
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6
 
Compiler presention
Compiler presentionCompiler presention
Compiler presention
 
lecture8_Cuong.ppt
lecture8_Cuong.pptlecture8_Cuong.ppt
lecture8_Cuong.ppt
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
LECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdfLECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdf
 
LECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdfLECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdf
 

Dernier

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Dernier (20)

Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

Code Tuning

  • 1. Code Tuning Techniques Most examples from Code Complete 2
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.