Generate Server-Timing headers interactively by setting timers in NodeJS
npm install servertiming --save
var ServerTiming = ;var timing = ;var queryTimer = timing;// ... do something work-intensivevar timeInMS = queryTimer;// or; var timeInMS = timing.stopTimer("Database Query");// you can also add metrics without the timer function// the time value is always in milliseconds!timing// If an operation you are timing fails before the// timer can be stopped, you can clear that timertrytiming;throw "The operation failed!";timing;catch etiming;// ... use the header string within your server framework or whateverres;return res;// this will output:// database-query; dur=122; desc="Database Query",image-processing; dur=12847; desc="Image Processing"
See the /example folder for a detailed express.js example!