正文

编译问题1:About cpuTime.H2007-05-09 18:45:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/bioexplore/25753.html

分享到:

编译时遇到的问题:windows下没有sys/times.H头文件,及相应库文件,而在cpuTime.H中嵌入的该文件         #include <sys/times.H>解决方法:将该语句注释掉在该类的实现代码里将相应的方法用其他函数替代掉:对cpuTime.H的修改:#ifndef cpuTime_H#define cpuTime_H #include <time.h> //bioexploreModify deinclude the <sys/times.h> which is not found //#include <sys/times.h>////bioexploreModifyEnd // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam{ /*---------------------------------------------------------------------------*\                           Class cpuTime Declaration\*---------------------------------------------------------------------------*/ class cpuTime{    // Private data    //bioexploreModify change long to double         static double Hz_;     //这里将long改成double型了,为了增加其容量    //bioexploreModifyEnd //bioexploreModify struct tms===> clock_t         clock_t startTime_;        //将tms结构改成time.H中定义的clock_t类型        mutable clock_t lastTime_;        mutable clock_t newTime_;         static void getTime(clock_t& t);         static double timeDifference        (            const clock_t& start,            const clock_t& end        );//bioexploreModifyEnd public:     // Constructors         //- Construct from components        cpuTime();     // Member Functions         // Access             //- Returns CPU time from start of run            double elapsedCpuTime() const;             //- Returns CPU time from last call of cpuTimeIncrement()            double cpuTimeIncrement() const;}; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif 以下是对该类实现代码进行的修改 // * * * * * * * * * * * * * * * Static Members  * * * * * * * * * * * * * * ////bioexploreModify sysconf(_SC_CLK_TCK)==>CLOCKS_PER_SEC and long==> double double cpuTime::Hz_(CLOCKS_PER_SEC); //bioexploreModifyEnd // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * ////bioexploreModify change struct tms===>clock_t void cpuTime::getTime(clock_t& t){    //bioexploreModify change times(&t)===>t=clock();     //times(&t);    t=clock();    //bioexploreModifyEnd } double cpuTime::timeDifference(    const clock_t& start,    const clock_t& end){    return    (        double        (            end           - start         )/Hz_    );} //bioexploreModifyEnd

阅读(3849) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册