#ifndef __TIME_MEASURE_H #define __TIME_MEASURE_H #include <sys/time.h> class time_measure{ public: /** * Get the current time */ time_measure(); /** * Calculate the time range(microseconds,i.e.10e-6 second) * and reset the tv_ to current time */ long int time_range(); private: timeval tv_; }; #endif
调用代码很简单: class test{ public: void print(){ cout<<"print OK"<<endl; } }; int main(){ time_measure t; my_application& my_app = my_application_singleton_holder::Instance(); my_app.insert_property("test",shared_ptr<test>(new test)); any a = my_app.get_property("test"); any_cast<shared_ptr<test> >(a)->print(); cout<<"time is:"<<t.time_range()<<" microseconds"<<endl; }
调用代码很简单: class test{ public: void print(){ cout<<"print OK"<<endl; } }; int main(){ time_measure t; my_application& my_app = my_application_singleton_holder::Instance(); my_app.insert_property("test",shared_ptr<test>(new test)); any a = my_app.get_property("test"); any_cast<shared_ptr<test> >(a)->print(); cout<<"time is:"<<t.time_range()<<" microseconds"<<endl; }