Homework & Coding Practice
Homework/Practice Coding Assignment (20-min)
Step-by-Step Procedure
Profile the API Built in Lesson 7 and Identify Areas for Performance Improvement:
Step 1: Run the API with
clinic:bash코드 복사clinic flame -- node server.jsStep 2: Use Postman to test all endpoints:
GET
/tasks.POST
/tasks.PUT
/tasks/:id.DELETE
/tasks/:id.
Step 3: Analyze the flamegraph:
Look for blocking tasks.
Check the time taken for database or JSON processing.
Step 4: Optimize the API:
Replace synchronous operations (e.g.,
fs.readFileSync) with asynchronous ones.Ensure routes are properly optimized for performance.
Write a Summary of Your Debugging Experience:
Key Points to Address:
Tools used for debugging (
debugger,clinic).Common issues identified and their root causes.
Steps taken to resolve issues.
Insights gained from profiling and performance metrics.
Example Summary:
markdown코드 복사Debugging Experience Summary:
1. Tools: Used `debugger` and `clinic.js` for identifying issues.
2. Issues: Found unoptimized synchronous operations in the `/tasks` route.
3. Solutions: Replaced blocking tasks with asynchronous calls and added proper error handling.
4. Outcome: Improved response time and reduced CPU usage.Expected Outcomes
Students gain hands-on experience with debugging and profiling Node.js applications.
Students learn to identify and resolve performance bottlenecks using tools like
clinic.js.Homework reinforces best practices for debugging and optimization in real-world applications.
Last updated