File tree Expand file tree Collapse file tree 3 files changed +69
-0
lines changed
97-Network Performance Analyzer Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments