Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create optimizations.md #305

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions practices/optimizations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
slug: optimizations
stages:
- development
short_description: Optimization is the process of modifying a software system to make some aspect of it work more efficiently or use fewer resources
tags:
- optimizations
- code coverage
keywords:
- code - quality
- merge
- testing
- codebase
---

# Optimizations

**TL;DR**

Optimization is an act, process, or methodology of making something (such as a design, system, or decision) as fully perfect, functional, or effective as possible
ng29 marked this conversation as resolved.
Show resolved Hide resolved

## What Is an Optimization
The code optimization in the synthesis phase is a program transformation technique, which tries to improve the intermediate code by making it consume fewer resources (i.e. CPU, Memory) so that faster-running machine code will result.
ng29 marked this conversation as resolved.
Show resolved Hide resolved

## Why You Might Want the Optimization

ng29 marked this conversation as resolved.
Show resolved Hide resolved
Optimizing an algorithm is beyond the scope of the code optimization phase. So the program is optimized. And it may involve reducing the size of the code. So optimization helps to:

- Reduce the space consumed and increases the speed of compilation.
ng29 marked this conversation as resolved.
Show resolved Hide resolved
- Manually analyzing datasets involves a lot of time. Hence we make use of software like Tableau for data analysis. Similarly manually performing the optimization is also tedious and is better done using a code optimizer.
- An optimized code often promotes re-usability.

## How to Implement the Optimization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, go more into how to implement optimization. I see that you have seen the https://www.thegeekstuff.com/2015/01/c-cpp-code-optimization/ based on the similarities. The article you use goes into C++ optimization, however, the scope of this article should go more into general techniques for optimization. Not only the code but also architecture as is mentioned in the corresponding issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need your help on this

Copy link
Contributor

@ridlees ridlees Oct 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, how I can help you?

Copy link
Contributor

@ridlees ridlees Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @ng29, how can I help you with this?

1. **Optimize your Code using Appropriate Algorithm**
2. **Optimize Your Code for Memory**
4. **Using Operators** : Most basic operations like +=, -=, and *=, when applied on basic data types could slow down the program as well.
5. **Problems with Functions** : For example, if you have a code like this, it might be a bad thing.
```
for(int i=1; i<=10; ++i)
DoSomething(i);
```
6. **Optimizing Loops**
7. **Data Structure Optimization**

## Common Pitfalls of the Optimization

ng29 marked this conversation as resolved.
Show resolved Hide resolved
- Time based optimization will give faster output, but it can lead up to a bigger code base. So to optimize the code for time performance may actually conflict with memory and size consumption. For that, you have to find the
balance between time and memory, in consideration to your requirement.
- Performance optimization is a never-ending process. There are always chances to improve and make your code run faster.
- Sometimes, we can be tempted to use certain programming methods to run faster at the expense of not following best practices like coding standards. Try to avoid any such kind of inappropriate methods.

## Resources for the Optimization
- Wikipedia: [Program Optimizations](https://en.wikipedia.org/wiki/Program_optimization)
- Einfochips: [ Goals of Optimization](https://www.einfochips.com/wp-content/uploads/resources/a-practical-approach-to-optimize-code-implementation.pdf)
- The Geek Stuff: [ Optimization Tips](https://www.thegeekstuff.com/2015/01/c-cpp-code-optimization/)