Improve your codebase
Tags: aws, programming, machinelearning, tutorial
Published: 2022-10-17 08:12:30

Find your most expensive lines of code in your codebase with AWS Code Guru in a matter of minutes.

_In today's world in which performance is a make-or-break factor and the focus is on minimizing costs. A good investment in your codebase is Amazon [CodeGuru ](https://aws.amazon.com/codeguru/)which will speed up and optimize your development process._

At the first glance, the latter might seem very enterprise oriented, but actually, you can leverage AWS [CodeGuru ](https://aws.amazon.com/codeguru/)in your personal projects.

**What is Amazon CodeGuru?**

Amazon [CodeGuru ](https://aws.amazon.com/codeguru/)is a machine-learning-powered solution for automating performance reviews and improving application performance. It does this by acting both on your code repositories and actual applications.

Amazon CodeGuru is comprised of two services: **CoduGuru Reviewer** and **CodeGuru Profiler**. 

- CodeGuru Profiler visualizes your application performance, showing you the methods that take the most time and CPU capacity to execute.

- CodeGuru Reviewer is what listens for pull requests in a repository and reviews code changes. When the Reviewer is associated with a repository, it will attempt to provide recommendations to help improve Java and Python code.

![How it works](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/66xhnfptw1efyp30ic1w.png)

**Improve your codebase in a matter of minutes!**

Basically, you just need to [associate your repo](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-amazon-codeguru-reviewer.html) with Amazon CodeGuru, and the nice part is that it supports source providers like GitHub or Bitbucket.

![Supported Repositories](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dtnj76au66yt26mijjv4.png)

To get started I'll onboard my Github repository to do a full analysis, it may take 30 seconds to associate the repository, and 5-10 minutes to create full repository analysis.

![CodeGuru Service](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ex811oytvc3jbvx8x09d.png)

After the analysis is done, you're going to find the recommendations for the specified code analysis.

![CodeGuru Analysis](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cy2mss2t4rrby4pjx85f.png)

And literally that's it, you can check the status of the code analysis in `AWS Console -> CodeGuru -> Code reviews`.

![CodeGuru analysis](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9ua4akyk3lkayvkisx9.png)

![CodeGuru analysis2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12nj5vnllhgqr0ft3ykk.png)

Next I'll check the Pull Request code review, for this I'll associate my [CodeCommit ](https://aws.amazon.com/codecommit/) repository, it can take a couple of minutes to  fully associate, but you can verify the status under the `Settings` of the repository, `Amazon CodeGuru Reviewer` tab.


![CodeGuru status](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dwx7gti8kd0vvyhumxhd.png)

When you submit a pull request to a CodeGuru associated code repository, the [Reviewer](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/welcome.html) will peruse the changes in the pull request and make recommendations based on its own analysis of millions of lines of external code, as comments on your file changes. 

For a Python codebase, you're going to see something like this and also a very useful feature is that you're going to have a link to [PEP](Python).

![CodeGuru pull-request 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h0zrp1t1llmhg6ng91a8.png)

CodeGuru Reviewer generates suggestions in its reviews as comments in pull requests.

![CodeGuru pull-request 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9psfx6aojf1lvpogalbp.png)

From the price point of view, you can get started with Amazon CodeGuru Reviewer at no cost, the Free Tier lasts 90 days for up to 100K lines of code in onboarded repositories per AWS account. When the 90-day Free Tier expires or your repository size exceeds 100K lines of code, you will pay standard pricing rates based on the repository size.

![AWS CodeGuru Pricing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rhzzj1oq2ca1vbbt3da0.png)

Additionally, if you deploy CodeGuru as an agent in your application, over time it will make observations and recommendations to help you find and fix code issues such as performance leaks, wasted CPU cycles, and more.