Skip to content
/ timeit Public

C/C++ macro for timing line/lines of code easily

Notifications You must be signed in to change notification settings

sunbuny/timeit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

timeit

C/C++ macro for timing line/lines of code easily, this marco doesn't need to create a lambda to test code. Also it doesn't broken the context of your code, it just insert timing code automatically. The use of __COUNTER__ may create unique variable name automatically, but the risk of naming conflicts still exists, please use with caution. And this macro can be easily disabled by defining DISABLE_TIMEIT.

examples

single line timing

#include <timeit.h>
#include <Eigen/Eigen> // e.g. use some thirdparty lib

TIMEIT("create a quaternion",  Eigen::Quaternion<double> q(2,0,1,-3);)

multi line timing

#include <timeit.h>
#include <Eigen/Eigen> // e.g. use some thirdparty lib

TIMEIT("create a quaternion and normalize it",  
Eigen::Quaternion<double> q(2,0,1,-3);
q.normalize();)

nested timing

#include <timeit.h>
#include <Eigen/Eigen> // e.g. use some thirdparty lib

TIMEIT("create a quaternion and normalize it",  
TIMEIT("create a quaternion",  Eigen::Quaternion<double> q(2,0,1,-3);)
TIMEIT("normalize a quaternion", q.normalize();)
)

disable timeit

#define DISABLE_TIMEIT
#include <timeit.h>

About

C/C++ macro for timing line/lines of code easily

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages