Giter Site home page Giter Site logo

chrono-benchmark's Introduction

chrono-benchmark

Small C++ class for chrono based benchmarks / time measurements

Example

Example code for the use of the benchmark class:

#include "benchmark.h"

void main() {

  benchmark time;

  time.start();

  for (uint32_t i = 0; i < 1000000; i++) 
  {
    // do nothing, just waste time
  }

  time.end();

  std::cout << "Consumed time in milliseocnds: " << time.get_ms();

}

Methods

void start()

Start the clock of the benchmark instance

void end()

End the clock of the benchmark and calculate the ellapsed time between start() and end() call.

µs_t get_µs()

Get the ellapsed time as microseconds

ms_t get_ms()

Get the ellapsed time as milliseconds

sec_t get_sec()

Get the ellapsed time as seconds

Constants

constexpr long double c_msfactor = 1000.0;

Conversion factor from microseconds to milliseconds

constexpr long double c_secFactor = 1000.0 * c_msfactor;

Conversion factor from microseconds to seconds

Types

New defined data types and their basic type:

Name Type
µs_t long double
ms_t long double
sec_t long double
time_point_t std::chrono::time_point<std::chrono::steady_clock>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.