Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions 97-Network Performance Analyzer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="styles.css" />
<title>Network Performance Analyzer</title>
</head>
<body>
<div class="container">
<h1>Network Performance Analyzer</h1>
<button id="analyzeButton">Analyze Performance</button>
<div id="resultContainer"></div>
</div>

<script src="script.js"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions 97-Network Performance Analyzer/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
document
.getElementById("analyzeButton")
.addEventListener("click", analyzePerformance);

function analyzePerformance() {
const startTime = performance.now();

// Simulate a network request (you can replace this with an actual request)
fetch("https://jsonplaceholder.typicode.com/todos/1")
.then((response) => response.json())
.then((data) => {
const endTime = performance.now();
const elapsedTime = endTime - startTime;

displayResult(elapsedTime);
})
.catch((error) => {
console.error("Error:", error);
displayResult("Error");
});
}

function displayResult(time) {
const resultContainer = document.getElementById("resultContainer");
resultContainer.innerHTML = `Network request completed in ${time.toFixed(
2
)} milliseconds.`;
}
23 changes: 23 additions & 0 deletions 97-Network Performance Analyzer/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
body {
font-family: Arial, sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}

.container {
text-align: center;
}

button {
padding: 10px 20px;
font-size: 16px;
margin: 10px;
}

#resultContainer {
margin-top: 20px;
font-size: 18px;
}