COptimize is a web-based tool that analyzes C code and suggests the best compiler optimization flag based on extracted features. The project leverages machine learning to predict the most suitable optimization setting, with a focus on reducing execution time by recommending flags such as -O0, -O1, -O2, -O3, and -Ofast for performance enhancement. 🎯📊💡
The application is hosted at: COptimize
- Upload C code as a file or paste it into a text box.
- Extracts static code features such as Lines of Code (LOC), loop counts, and conditionals.
- Uses a trained machine learning model to predict the best compiler optimization flag.
- Provides optimization recommendations instantly.
- Backend: Flask
- Machine Learning: scikit-learn (Random Forest Classifier)
- Frontend: HTML, CSS, JavaScript (via templates)
- Deployment: Render.com
To run the project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/Swoyamjeetcodes/coptimize.git cd coptimize -
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Run the Flask application:
python app.py
-
Open the application in your browser at:
http://localhost:5000
├── app.py # Flask application
├── model.py # Machine learning model for optimization
├── features.csv # Training dataset
├── requirements.txt # Dependencies
├── templates/ # HTML templates
├── static/ # Static assets (CSS, JS)
└── uploads/ # Directory for uploaded C files
- Visit the hosted application or run it locally.
- Upload a C file or enter code manually.
- Click submit to analyze the code.
- The application will predict and display the best optimization flag.
The required dependencies are listed in requirements.txt:
- Flask
- scikit-learn
- pycparser
- pandas
- numpy
- gunicorn
This project is licensed under the MIT License. 🎉⚖️📖