πŸ“Š Generate Server-Timing headers interactively in modern C++11
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
LICENSE
README.md
servertiming.hpp

README.md

Server-Timing

Generate Server-Timing headers interactively in modern C++11

Inpired by:

πŸ“Š View your server's metrics in @ChromeDevTools via Server Timing headers. Big thanks to longtime Firebug developer @sroussey for the patch! pic.twitter.com/OjDDIv0lLR

β€” Paul Irish (@paul_irish) February 7, 2017
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

Installation

The library is header-only. Just drop the servertiming.hpp in your project and use it. You'll need a modern C++11 compatible compiler though.

Usage

#include "servertiming.hpp"

ServerTiming timing();
timing.startTimer("Database Query");

// ... do something work-intensive

timing.stopTimer("Database Query");

// you can also add metrics without the timer function
// the time value is always in milliseconds!
timing.addMetric("Image Processing", 12365)

// ... use the header string within your server framework or whatever
std::string header = timing.generateHeader();

// this will output:
// database-query;dur=0.122;desc="Database Query",image-processing;dur=12.365;desc="Image Processing"