Skip to content

Commit a75fe93

Browse files
Merge pull request #128 from pradipchaudhary/project97
init basic network performance app [project97]
2 parents f23e52e + d675a9a commit a75fe93

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<link rel="stylesheet" href="styles.css" />
7+
<title>Network Performance Analyzer</title>
8+
</head>
9+
<body>
10+
<div class="container">
11+
<h1>Network Performance Analyzer</h1>
12+
<button id="analyzeButton">Analyze Performance</button>
13+
<div id="resultContainer"></div>
14+
</div>
15+
16+
<script src="script.js"></script>
17+
</body>
18+
</html>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
document
2+
.getElementById("analyzeButton")
3+
.addEventListener("click", analyzePerformance);
4+
5+
function analyzePerformance() {
6+
const startTime = performance.now();
7+
8+
// Simulate a network request (you can replace this with an actual request)
9+
fetch("https://jsonplaceholder.typicode.com/todos/1")
10+
.then((response) => response.json())
11+
.then((data) => {
12+
const endTime = performance.now();
13+
const elapsedTime = endTime - startTime;
14+
15+
displayResult(elapsedTime);
16+
})
17+
.catch((error) => {
18+
console.error("Error:", error);
19+
displayResult("Error");
20+
});
21+
}
22+
23+
function displayResult(time) {
24+
const resultContainer = document.getElementById("resultContainer");
25+
resultContainer.innerHTML = `Network request completed in ${time.toFixed(
26+
2
27+
)} milliseconds.`;
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
body {
2+
font-family: Arial, sans-serif;
3+
display: flex;
4+
align-items: center;
5+
justify-content: center;
6+
height: 100vh;
7+
margin: 0;
8+
}
9+
10+
.container {
11+
text-align: center;
12+
}
13+
14+
button {
15+
padding: 10px 20px;
16+
font-size: 16px;
17+
margin: 10px;
18+
}
19+
20+
#resultContainer {
21+
margin-top: 20px;
22+
font-size: 18px;
23+
}

0 commit comments

Comments
 (0)