pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:8426:    pop_n_elems(args);    o = get_master();    if (o) ref_push_object(o);    else push_undefined();   }      #ifdef HAVE_SYS_TIME_H   #include <sys/time.h>   #endif    - /*! @decl int gethrvtime (void|int nsec) -  *! -  *! Return the CPU time that has been consumed by this process or -  *! thread. -1 is returned if the system couldn't determine it. The -  *! time is normally returned in microseconds, but if the optional -  *! argument @[nsec] is nonzero it's returned in nanoseconds. -  *! -  *! The CPU time includes both user and system time, i.e. it's -  *! approximately the same thing you would get by adding together the -  *! "utime" and "stime" fields returned by @[System.getrusage] (but -  *! perhaps with better accuracy). -  *! -  *! It's however system dependent whether or not it's the time -  *! consumed in all threads or in the current one only; -  *! @[System.CPU_TIME_IS_THREAD_LOCAL] tells which. If both types are -  *! available then thread local time is preferred. -  *! -  *! @note -  *! The actual accuracy on many systems is significantly less than -  *! microseconds or nanoseconds. See @[System.CPU_TIME_RESOLUTION]. -  *! -  *! @note -  *! The garbage collector might run automatically at any time. The -  *! time it takes is not included in the figure returned by this -  *! function, so that normal measurements aren't randomly clobbered -  *! by it. Explicit calls to @[gc] are still included, though. -  *! -  *! @note -  *! The special function @[gauge] is implemented with this function. -  *! -  *! @seealso -  *! @[System.CPU_TIME_IS_THREAD_LOCAL], @[System.CPU_TIME_RESOLUTION], -  *! @[gauge()], @[System.getrusage()], @[gethrtime()] -  */ - PMOD_EXPORT void f_gethrvtime(INT32 args) + #ifdef CPU_TIME_MIGHT_BE_THREAD_LOCAL + void thread_gethrvtime(struct thread_state * ts, INT32 args) + #else + void thread_gethrvtime(INT32 args) + #endif   {    int nsec = 0;    cpu_time_t time = get_cpu_time();       if (time == (cpu_time_t) -1) {    pop_n_elems (args);    push_int (-1);    return;    }      #ifdef CPU_TIME_MIGHT_BE_THREAD_LOCAL    if (cpu_time_is_thread_local) -  time -= Pike_interpreter.thread_state->auto_gc_time; +  time -= ts->auto_gc_time;    else   #endif    {   #ifdef CPU_TIME_MIGHT_NOT_BE_THREAD_LOCAL    time -= auto_gc_time;   #endif    }       nsec = args && !UNSAFE_IS_ZERO(Pike_sp-args);   
pike.git/src/builtin_functions.c:8504: Inside #if CPU_TIME_TICKS_LOW > 1000000
  #if CPU_TIME_TICKS_LOW > 1000000    push_int64(time / (CPU_TIME_TICKS / 1000000));   #else    push_int64 (time);    push_int (1000000 / CPU_TIME_TICKS);    o_multiply();   #endif    }   }    + /*! @decl int gethrvtime (void|int nsec) +  *! +  *! Return the CPU time that has been consumed by this process or +  *! thread. -1 is returned if the system couldn't determine it. The +  *! time is normally returned in microseconds, but if the optional +  *! argument @[nsec] is nonzero it's returned in nanoseconds. +  *! +  *! The CPU time includes both user and system time, i.e. it's +  *! approximately the same thing you would get by adding together the +  *! "utime" and "stime" fields returned by @[System.getrusage] (but +  *! perhaps with better accuracy). +  *! +  *! It's however system dependent whether or not it's the time +  *! consumed in all threads or in the current one only; +  *! @[System.CPU_TIME_IS_THREAD_LOCAL] tells which. If both types are +  *! available then thread local time is preferred. +  *! +  *! @note +  *! The actual accuracy on many systems is significantly less than +  *! microseconds or nanoseconds. See @[System.CPU_TIME_RESOLUTION]. +  *! +  *! @note +  *! The garbage collector might run automatically at any time. The +  *! time it takes is not included in the figure returned by this +  *! function, so that normal measurements aren't randomly clobbered +  *! by it. Explicit calls to @[gc] are still included, though. +  *! +  *! @note +  *! The special function @[gauge] is implemented with this function. +  *! +  *! @seealso +  *! @[System.CPU_TIME_IS_THREAD_LOCAL], @[System.CPU_TIME_RESOLUTION], +  *! @[gauge()], @[System.getrusage()], @[gethrtime()] +  */ + PMOD_EXPORT void f_gethrvtime(INT32 args) + { + #ifdef CPU_TIME_MIGHT_BE_THREAD_LOCAL +  thread_gethrvtime(Pike_interpreter.thread_state, args); + #else +  thread_gethrvtime(args); + #endif + } +    /*! @decl int gethrtime (void|int nsec)    *!    *! Return the high resolution real time since some arbitrary event in    *! the past. The time is normally returned in microseconds, but if    *! the optional argument @[nsec] is nonzero it's returned in    *! nanoseconds.    *!    *! It's system dependent whether or not this time is monotonic, i.e.    *! if it's unaffected by adjustments of the calendaric clock in the    *! system. @[System.REAL_TIME_IS_MONOTONIC] tells what it is. Pike