Skip to content

Commit 2343c23

Browse files
init basic code profiler and optimizer app [project91]
1 parent e4d7034 commit 2343c23

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Code Profiler and Optimizer</title>
7+
<link rel="stylesheet" href="styles.css" />
8+
</head>
9+
<body>
10+
<header>
11+
<h1>Code Profiler and Optimizer</h1>
12+
</header>
13+
14+
<main>
15+
<div class="code-container">
16+
<textarea
17+
id="codeInput"
18+
placeholder="Enter your code here..."
19+
></textarea>
20+
</div>
21+
22+
<div class="profile-results">
23+
<h2>Profile Results</h2>
24+
<p>Total Characters: <span id="charCount">0</span></p>
25+
</div>
26+
27+
<button id="optimizeBtn">Optimize Code</button>
28+
<div class="optimized-code">
29+
<h2>Optimized Code</h2>
30+
<pre id="optimizedCode"></pre>
31+
</div>
32+
</main>
33+
34+
<script src="script.js"></script>
35+
</body>
36+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!--
2+
3+
Notes:-
4+
5+
Creating a full-fledged code profiler and optimizer is quite complex, and building a comprehensive tool may require server-side components and advanced algorithms. However, I can provide you with a basic example of a code profiler and optimizer using HTML, CSS, and JavaScript. This example will focus on basic syntax highlighting and character count profiling.
6+
7+
8+
This example provides a basic UI for entering code, profiling its character count, and applying a simple optimization (removing extra whitespaces). For a more advanced code profiler and optimizer, you might want to explore third-party libraries and tools or consider server-side solutions for more intensive optimizations.
9+
10+
11+
-->
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
document.addEventListener("DOMContentLoaded", function () {
2+
const codeInput = document.getElementById("codeInput");
3+
const charCount = document.getElementById("charCount");
4+
const optimizeBtn = document.getElementById("optimizeBtn");
5+
const optimizedCode = document.getElementById("optimizedCode");
6+
7+
// Update character count on input
8+
codeInput.addEventListener("input", function () {
9+
const code = codeInput.value;
10+
charCount.textContent = code.length;
11+
});
12+
13+
// Optimize code on button click
14+
optimizeBtn.addEventListener("click", function () {
15+
const code = codeInput.value;
16+
17+
// Basic optimization example: remove extra whitespaces
18+
const optimized = code.replace(/\s+/g, " ");
19+
20+
optimizedCode.textContent = optimized;
21+
});
22+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
body {
2+
font-family: "Arial", sans-serif;
3+
margin: 0;
4+
padding: 0;
5+
}
6+
7+
header,
8+
main {
9+
margin: 20px;
10+
}
11+
12+
.code-container {
13+
margin-bottom: 20px;
14+
}
15+
16+
textarea {
17+
width: 100%;
18+
height: 200px;
19+
padding: 10px;
20+
}
21+
22+
button {
23+
background-color: #4caf50;
24+
color: white;
25+
padding: 10px 20px;
26+
border: none;
27+
cursor: pointer;
28+
}
29+
30+
button:hover {
31+
background-color: #45a049;
32+
}
33+
34+
.profile-results {
35+
margin-bottom: 20px;
36+
}
37+
38+
#optimizedCode {
39+
white-space: pre-wrap;
40+
}

0 commit comments

Comments
 (0)