Inspiration
The inspiration behind our Code Optimizing Bot is the significant impact that poorly written code can have on energy consumption and electricity usage. Inefficient code can lead to unnecessary resource consumption, resulting in increased energy consumption and environmental impact. Our aim is to help developers identify and optimize their code to improve its time efficiency, reducing energy consumption and promoting sustainable software development.
What it does
Code Optimizing Bot is a VS Code extension that retrospectively scans your code to identify areas where you can improve the time efficiency of your code. It specifically focuses on optimizing loops such as for loops and while loops, which are common performance bottlenecks in many programs. By suggesting optimized alternatives or providing insights on how to improve the efficiency of the existing loops, the bot aims to help developers write more efficient and sustainable code.
How we built it
We built the Code Optimizing Bot as a VS Code extension using JavaScript. The extension leverages the power of the VS Code extension API to analyze the code in the active editor and provide suggestions for code optimization. To optimize loops, we utilize the capabilities of a language model (LLM) by making requests to an LLM backend. We pass the code snippets containing loops to the LLM and receive optimized versions of the loops as responses.
However, one of the challenges we encountered was the delay in making requests to the LLM. Each request took a few seconds to complete, which impacted the responsiveness of the extension. Despite this challenge, we were able to develop a minimum viable product (MVP) that successfully identifies loops for optimization and provides suggestions for improvement.
Challenges we ran into
Again, one of the main challenges we faced was the delay in making requests to the LLM. Since each request took a few seconds, it impacted the overall performance and responsiveness of the Code Optimizing Bot.
Accomplishments that we're proud of
We are proud of developing the projected MVP for the Code Optimizing Bot, especially considering that it was our first experience building a VS Code extension. Despite the challenges with query times to the LLM, we were able to incorporate code analysis and suggestion features to help developers optimize their loops. It showcases our ability to learn new technologies and deliver a functional tool within the given timeframe.
What we learned
During the development of the Code Optimizing Bot, we learned valuable lessons about building VS Code extensions and integrating external services like language models. We gained experience in utilizing the VS Code extension API and handling the complexities of making requests to the LLM. We also improved our understanding of code optimization techniques and the importance of efficient coding practices for energy efficiency.
What's next for Code Optimizing Bot
In the future, we plan to improve the query times to the LLM by optimizing the way we send code snippets for analysis. Currently, we query the entire codebase up until the loop to be optimized, which can be inefficient for larger projects. By making better use of Abstract Syntax Trees (ASTs) and providing context-specific information to the LLM, we can enhance the query time and response accuracy.
Additionally, we aim to expand the capabilities of the Code Optimizing Bot to account for other common code inefficiencies, such as functions from external modules or functions from other files that have high time complexity. By identifying and suggesting improvements for these code patterns, we can further assist developers in optimizing their code and reducing energy consumption.
Built With
- javascript
- llm
- openai
Log in or sign up for Devpost to join the conversation.