Skip to content

Commit db49c80

Browse files
authored
Update README.md
1 parent 7d412ae commit db49c80

File tree

1 file changed

+105
-9
lines changed

1 file changed

+105
-9
lines changed

README.md

Lines changed: 105 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,105 @@
1-
<h1>Code Complexity Analyzer</h1>
2-
<p>Welcome to the Code Complexity Analyzer, a comprehensive web tool designed to help developers understand and optimize the time complexity of their code. This tool utilizes the least squares method to accurately fit the best match graph, drawing from detailed nano time measurements across Java, C++, and Python.</p>
3-
4-
<h2>Key Features:</h2>
5-
<ul>
6-
<li><strong>Multi-Language Support</strong>: Analyze and compare code efficiency in Java, C++, and Python.</li>
7-
<li><strong>Algorithm Learning</strong>: Engage with different types of algorithms and data structures.</li>
8-
<li><strong>Interactive Quizzes</strong>: Test your understanding and apply what you've learned through interactive quizzes tailored to each programming language.</li>
9-
</ul>
1+
2+
# Time Complexity Analyzer
3+
4+
## Overview
5+
The **Time Complexity Analyzer** is a powerful tool for code profiling, designed to measure runtime and provide insights into the performance of functions. While the tool approximates the time complexity of functions, its accuracy is limited due to the inherent challenges of data fitting and model simplification.
6+
7+
---
8+
9+
## Key Features
10+
### 1. Code Profiling and Runtime Analysis
11+
- **Precise Runtime Measurement**:
12+
- Tracks execution time for each line of code.
13+
- Provides the total runtime of functions.
14+
- **Profiling Features**:
15+
- Outputs detailed runtime logs for in-depth performance evaluation.
16+
- Highlights performance bottlenecks in functions.
17+
18+
### 2. Time Complexity Approximation
19+
- Approximates the time complexity of functions using fitted mathematical models.
20+
- **Limitations**:
21+
- The approximations may not always reflect the actual complexity, especially for functions with edge cases or unusual input distributions.
22+
- Relies on data fitting, which introduces inaccuracies for complex or nonstandard patterns.
23+
24+
### 3. Algorithm Database
25+
- A repository of algorithms with:
26+
- Definitions and code examples.
27+
- Instructional videos and quizzes to support learning.
28+
29+
### 4. User Authentication
30+
- Secure sign-up and login to provide personalized access to profiling data and analysis reports.
31+
32+
---
33+
34+
## How Runtime is Calculated
35+
- The tool uses **instrumentation** to insert profiling hooks into the code.
36+
- For each line or function:
37+
- Start and end timestamps are recorded.
38+
- The difference between these timestamps gives the execution time.
39+
- Outputs include:
40+
- Execution time for each individual line of code.
41+
- Total runtime for the entire function.
42+
43+
---
44+
45+
## How Time Complexity is Approximated
46+
### Least Squares Method
47+
The tool applies the "least squares method" to fit runtime data to known mathematical models. Here’s how it works:
48+
49+
1. Collect Data:
50+
- The runtime for various input sizes (x_data) and corresponding execution times (y_data) are recorded.
51+
52+
2. Error Function:
53+
- The error between the observed execution times and the model predictions is minimized.
54+
- For a given model f(x, params), the error function is:
55+
Error = Σ [y_i - f(x_i, params)]^2
56+
57+
3. Optimization:
58+
- Numerical optimization techniques (e.g., least_squares from scipy.optimize) are used to adjust the parameters of the model until the error is minimized.
59+
60+
4. Model Selection:
61+
- The tool evaluates multiple models (e.g., linear, logarithmic, quadratic) and selects the one with the lowest residual sum of squares (RSS).
62+
- Overly complex models are penalized to avoid overfitting.
63+
64+
65+
---
66+
67+
## Screenshots
68+
69+
### Main Page
70+
![Main Page](./images/main_page.png)
71+
72+
### Code Output
73+
![Code Output](./images/code_output.png)
74+
75+
### History
76+
![History](./images/history.png)
77+
78+
### Login/Sign Up
79+
![Login/Sign Up](./images/login_signup.png)
80+
81+
### Learning Page
82+
![Learning Page](./images/learning_page.png)
83+
84+
---
85+
86+
## Limitations
87+
1. **Accuracy of Time Complexity Approximation**:
88+
- Limited by the quality of data fitting and the assumptions made by the mathematical models.
89+
- Small coefficients or inappropriate constants can lead to misleading results.
90+
2. **Single-Array Functions**:
91+
- Only supports functions with a single array as input.
92+
3. **External Calls**:
93+
- Cannot measure execution time for functions that rely on external calls.
94+
95+
---
96+
97+
## Areas for Improvement
98+
- **Better Runtime Modeling**:
99+
- Explore advanced optimization methods like robust regression or Bayesian optimization for improved fitting accuracy.
100+
- **Enhanced Profiling**:
101+
- Add support for functions with multiple input types and external calls.
102+
- **Sophisticated Input Handling**:
103+
- Improve input generation methods to better reflect real-world scenarios.
104+
105+
---

0 commit comments

Comments
 (0)