Getting Started

Prerequisites

To use Measuro in your application you will need at minimum:

  • cmake >= 2.6

  • A fully-compliant C++14 compiler - g++ 6.1 or above recommended. Measuro has not been tested with other compilers (though it will probably be easy to get building in those that have implemented the standard).

    If you are using a version of g++ < 6.1, you will need to supply the -std=c++14 switch to enable C++14 mode.

  • To link against pthread, e.g. -lpthread

It’s recommended you use Measuro as a sub-module in your application’s repository, and include the header file by specifying the Measuro src directory as a search path.

To run the Measuro test suite you will need:

  • C++14 compiler, as above
  • cmake >= 2.6
  • gtest development package (unit testing framework)
  • valgrind, for dynamic analysis
  • cppcheck, for static analysis
  • Python >= 2.6

Installing

See the README.rst file in the root of the Measuro repository.

Hello World Example

For a comprehensive guide to using Measuro, see Developer Guide.

#include <iostream>
#include <string>
#include <measuro/measuro.hpp>

int main(int argc, char * argv[])
{
    // The Registry object tracks all the app's metrics
    measuro::Registry reg;

    // Create a string metric called Hello with an initial value of an
    // empty string
    auto metric = reg.create_metric(measuro::STR::KIND, "Hello",
                      "My first metric", "");

    // Create a renderer that will render the registry's metrics as plain
    // text key-value pairs to stdout
    measuro::PlainRenderer renderer(std::cout);

    // Perform a render
    reg.render(renderer);

    // Give the Hello metric a new value
    *metric = "World";

    // Render again
    reg.render(renderer);

    return 0;
}