2018-05-30 21:34:38 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* libretroshare/src/util: rstime.h *
|
|
|
|
* *
|
|
|
|
* libretroshare: retroshare core library *
|
|
|
|
* *
|
|
|
|
* Copyright 2013-2013 by Cyril Soler <csoler@users.sourceforge.net> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Lesser General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2015-08-11 23:19:37 +02:00
|
|
|
#include <string>
|
2013-10-20 13:29:24 +00:00
|
|
|
|
2018-01-27 20:22:31 +01:00
|
|
|
namespace rstime {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief This is a cross-system definition of usleep, which accepts any 32 bits number of micro-seconds.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int rs_usleep(uint32_t micro_seconds);
|
|
|
|
|
|
|
|
/* Use this class to measure and display time duration of a given environment:
|
|
|
|
|
|
|
|
{
|
|
|
|
RsScopeTimer timer("callToMeasure()") ;
|
|
|
|
|
|
|
|
callToMeasure() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
class RsScopeTimer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsScopeTimer(const std::string& name);
|
|
|
|
~RsScopeTimer();
|
|
|
|
|
|
|
|
void start();
|
|
|
|
double duration();
|
2013-10-19 20:54:42 +00:00
|
|
|
|
2018-01-27 20:22:31 +01:00
|
|
|
static double currentTime();
|
2013-10-20 13:29:24 +00:00
|
|
|
|
2018-01-27 20:22:31 +01:00
|
|
|
private:
|
|
|
|
std::string _name ;
|
|
|
|
double _seconds ;
|
|
|
|
};
|
2013-10-19 20:54:42 +00:00
|
|
|
|
2018-01-27 20:22:31 +01:00
|
|
|
}
|