Skip to content

πŸ“Š Generate Server-Timing headers interactively in modern C++11

License

Notifications You must be signed in to change notification settings

thomasbrueggemann/cpp-servertiming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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"

About

πŸ“Š Generate Server-Timing headers interactively in modern C++11

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages