#include "pip.h"

//! [delimiter]
void tfunc(int delim) {
	piCout << "tick with delimiter" << delim;
};
void tfunc4(int delim) {
	piCout << "tick4 with delimiter" << delim;
};
int main() {
	PITimer timer(tfunc);
	timer.addDelimiter(2);
	timer.addDelimiter(4, tfunc4);
	timer.start(50);
	piMSleep(200);
	timer.stopAndWait();
	return 0;
};
/* Result:
tick with delimiter 1
tick with delimiter 1
tick with delimiter 2
tick with delimiter 1
tick with delimiter 1
tick with delimiter 2
tick4 with delimiter 4
*/
//! [delimiter]
//! [elapsed]
int main() {
	PITimeMeasurer tm;
	piMSleep(100);
	piCout << "elapsed" << tm.elapsed_m() << "ms";
	piMSleep(100);
	piCout << "elapsed" << tm.elapsed_m() << "ms";
	tm.reset();
	piMSleep(150);
	piCout << "elapsed" << tm.elapsed_s() << "s";
	return 0;
};
/* Result:
elapsed 100 ms
elapsed 200 ms
elapsed 0.15 s
*/
//! [elapsed]
//! [system_time]
int main() {
	PISystemTime t0;                      // s = ns = 0
	t0.addMilliseconds(200);              // s = 0, ns = 200000000
	t0.addMilliseconds(900);              // s = 1, ns = 100000000
	t0 -= PISystemTime::fromSeconds(0.1); // s = 1, ns = 0
	t0.sleep();                           // sleep for 1 second
	PISystemTime t1;
	t0 = PISystemTime::current();
	piMSleep(500);
	t1 = PISystemTime::current();
	(t1 - t0).sleep(); // sleep for 500 milliseconds
	return 0;
};
//! [system_time]

void _(){


};
