kusano 7d535a
/*! @file superlu_timer.c
kusano 7d535a
 * \brief Returns the time used
kusano 7d535a
 *
kusano 7d535a
 * 
kusano 7d535a
 * Purpose
kusano 7d535a
 * ======= 
kusano 7d535a
 * 
kusano 7d535a
 * Returns the time in seconds used by the process.
kusano 7d535a
 *
kusano 7d535a
 * Note: the timer function call is machine dependent. Use conditional
kusano 7d535a
 *       compilation to choose the appropriate function.
kusano 7d535a
 * 
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
#ifdef SUN 
kusano 7d535a
/*
kusano 7d535a
 * 	It uses the system call gethrtime(3C), which is accurate to 
kusano 7d535a
 *	nanoseconds. 
kusano 7d535a
*/
kusano 7d535a
#include <sys time.h=""></sys>
kusano 7d535a
kusano 7d535a
double SuperLU_timer_() {
kusano 7d535a
    return ( (double)gethrtime() / 1e9 );
kusano 7d535a
}
kusano 7d535a
kusano 7d535a
#elif _WIN32
kusano 7d535a
kusano 7d535a
#include <time.h></time.h>
kusano 7d535a
kusano 7d535a
double SuperLU_timer_()
kusano 7d535a
{
kusano 7d535a
    clock_t t;
kusano 7d535a
    t=clock();
kusano 7d535a
kusano 7d535a
    return ((double)t)/CLOCKS_PER_SEC;
kusano 7d535a
}
kusano 7d535a
kusano 7d535a
#else
kusano 7d535a
kusano 7d535a
#ifndef NO_TIMER
kusano 7d535a
#include <sys types.h=""></sys>
kusano 7d535a
#include <sys times.h=""></sys>
kusano 7d535a
#include <time.h></time.h>
kusano 7d535a
#include <sys time.h=""></sys>
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#ifndef CLK_TCK
kusano 7d535a
#define CLK_TCK 60
kusano 7d535a
#endif
kusano 7d535a
/*! \brief Timer function
kusano 7d535a
 */ 
kusano 7d535a
double SuperLU_timer_()
kusano 7d535a
{
kusano 7d535a
#ifdef NO_TIMER
kusano 7d535a
    /* no sys/times.h on WIN32 */
kusano 7d535a
    double tmp;
kusano 7d535a
    tmp = 0.0;
kusano 7d535a
#else
kusano 7d535a
    struct tms use;
kusano 7d535a
    double tmp;
kusano 7d535a
    times(&use);
kusano 7d535a
    tmp = use.tms_utime;
kusano 7d535a
    tmp += use.tms_stime;
kusano 7d535a
#endif
kusano 7d535a
    return (double)(tmp) / CLK_TCK;
kusano 7d535a
}
kusano 7d535a
kusano 7d535a
#endif
kusano 7d535a