mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
31 lines
742 B
C++
31 lines
742 B
C++
#ifndef OAKBENCHMARK_H_RNPP99KX
|
|
#define OAKBENCHMARK_H_RNPP99KX
|
|
|
|
#include <oak/duration.h>
|
|
#include "OakDebug.h"
|
|
|
|
namespace oak
|
|
{
|
|
template <typename DBF>
|
|
struct benchmark_t
|
|
{
|
|
typedef std::shared_ptr< benchmark_t<DBF> > ptr;
|
|
|
|
benchmark_t (DBF flag, std::string const& message) : flag(flag), message(message), timer() { }
|
|
~benchmark_t ()
|
|
{
|
|
D(flag, bug("%s ran in %.2fs\n", message.c_str(), timer.duration()););
|
|
}
|
|
|
|
private:
|
|
DBF flag;
|
|
std::string message;
|
|
oak::duration_t timer;
|
|
};
|
|
}
|
|
|
|
#define BENCHMARK(DBF, message) \
|
|
if(oak::benchmark_t<decltype(DBF)>::ptr _benchmark = oak::benchmark_t<decltype(DBF)>::ptr(new oak::benchmark_t<decltype(DBF)>(DBF, message)))
|
|
|
|
#endif /* end of include guard: OAKBENCHMARK_H_RNPP99KX */
|