An open API service indexing awesome lists of open source software.

https://github.com/maurodelazeri/elapsed_timer

header-only lib record time elapsed using C++11
https://github.com/maurodelazeri/elapsed_timer

cpp elapsed-time header-only library

Last synced: 3 months ago
JSON representation

header-only lib record time elapsed using C++11

Awesome Lists containing this project

README

        

Elapsed time for code blocks execution written in C++11

This is a simple header-only library `elapsed.h` just import in your project and you are ready to go...

Here an example...

```C++
#include
#include "elapsed.h"
#include "iostream"

using namespace std;

void Fibonacci()
{
int t1 = 0, t2 = 1, nextTerm = 0, n;
n = 10;
cout << "Fibonacci Series: " << t1 << ", " << t2 << ", ";
nextTerm = t1 + t2;
while(nextTerm <= n)
{
cout << nextTerm << ", ";
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
}
}

int main() {
{
Elapsed elapsed;
Fibonacci();
}
{
auto elapsed = make_unique("Fibonacci func execution");
Fibonacci();
}
return 0;
}
```

Basically when `Elapsed elapsed;` go out of scope it will automatically display the elapsed time in `std::cout`

The execution above will produce something like:

```
Fibonacci Series: 0, 1, 1, 2, 3, 5, 8,
[ Elapsed time: : 15 us ]
Fibonacci Series: 0, 1, 1, 2, 3, 5, 8,
[ Fibonacci func execution : 1 us ]
```