2013-09-08 05:33:18 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <iostream>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
/**
|
|
|
|
\brief Low tech timer for used for testing.
|
|
|
|
*/
|
|
|
|
class timeit {
|
|
|
|
std::ostream & m_out;
|
|
|
|
std::string m_msg;
|
|
|
|
clock_t m_start;
|
|
|
|
public:
|
|
|
|
timeit(std::ostream & out, char const * msg):m_out(out), m_msg(msg) {
|
|
|
|
m_start = clock();
|
|
|
|
}
|
|
|
|
~timeit() {
|
|
|
|
clock_t end = clock();
|
2013-09-09 06:10:33 +00:00
|
|
|
m_out << m_msg << " " << ((static_cast<double>(end) - static_cast<double>(m_start)) / CLOCKS_PER_SEC) << " secs\n";
|
2013-09-08 05:33:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|