מתוך התוכנית או מחוץ לה?
אם אתה רוצה מדידה מתוך התוכנית, אתה יכול להשתמש בזה:
#include <ctime> class Timer { clock_t timestart_; clock_t timestop_; public: Timer() : timestart_(NULL), timestop_(NULL){}; virtual ~Timer(){}; void start() { timestart_ = clock(); } void stop() { timestop_ = clock(); } double diff() { double diff = (double)(timestop_ - timestart_)/CLOCKS_PER_SEC; return diff; } };
שים את המחלקה ב-header file, ותכליל אותו בקובץ בו אתה רוצה להשתמש בו. צור אוביקט Timer, ואז השתמש ב-start, stop ו-diff . בהצלחה.