⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gettimer.c

📁 执行EXP计算的快速算法实现源码, Visual C++ 6.0 环境下编译通过.
💻 C
字号:
/* --------------------------------------------------------------
    Timer function.

    Home page: www.imach.uran.ru/rns

    Copyright 2001-2002 by Dr. Raul N.Shakirov, IMach of RAS(UB).
    All Rights Reserved.

    Permission has been granted to copy, distribute and modify
    software in any context without fee, including a commercial
    application, provided that the aforesaid copyright statement
    is present here as well as exhaustive description of changes.

    THE SOFTWARE IS DISTRIBUTED "AS IS". NO WARRANTY OF ANY KIND
    IS EXPRESSED OR IMPLIED. YOU USE AT YOUR OWN RISK. THE AUTHOR
    WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR
    ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.
-------------------------------------------------------------- */

#include <time.h>       /* Header file for standard time functions */
#include "gettimer.h"   /* Header file for GetTimer() function */

/* --------------------------------------------------------------
    Macros for conversion of clock ticks to mls to and vice versa.
-------------------------------------------------------------- */

#ifndef CLK_TCK
#define CLK_TCK CLOCKS_PER_SEC
#endif/*CLK_TCK*/

#define CLKTOMLS(clk) ((clock_t)((clk) * (1000. / CLK_TCK)))
#define MLSTOCLK(mls) ((clock_t)((mls) * (CLK_TCK / 1000.)))

#ifdef  __cplusplus
extern "C" {
#endif/*__cplusplus*/

/* --------------------------------------------------------------
    Name:       GetTimer

    Purpose:    Get timer as a millisecond interval between
                current time and given time value.

    Usage:      long timer = GetTimer (0);
                ...
                Some time-consuming process
                ...
                timer = GetTimer (timer);

    Arguments:
      timer     Time value to be subtracted from current time.

    Returns:    Difference of current time and timer value.
-------------------------------------------------------------- */

long GetTimer (long timer)
{
    long time = (long) CLKTOMLS (clock()) - timer;

    /* Correct time after midnight */

    if (time < 0) time += (24 * 3600 * 1000L);

    return (time);
}

#ifdef  __cplusplus
}
#endif/*__cplusplus*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -