/scipy/sparse/linalg/dsolve/SuperLU/SRC/superlu_timer.c

https://github.com/jsilter/scipy · C · 72 lines · 37 code · 14 blank · 21 comment · 0 complexity · 5faf3c9021f59c3f77b76f64f765b1c9 MD5 · raw file

  1. /*! @file superlu_timer.c
  2. * \brief Returns the time used
  3. *
  4. * <pre>
  5. * Purpose
  6. * =======
  7. *
  8. * Returns the time in seconds used by the process.
  9. *
  10. * Note: the timer function call is machine dependent. Use conditional
  11. * compilation to choose the appropriate function.
  12. * </pre>
  13. */
  14. #ifdef SUN
  15. /*
  16. * It uses the system call gethrtime(3C), which is accurate to
  17. * nanoseconds.
  18. */
  19. #include <sys/time.h>
  20. double SuperLU_timer_() {
  21. return ( (double)gethrtime() / 1e9 );
  22. }
  23. #elif _WIN32
  24. #include <time.h>
  25. double SuperLU_timer_()
  26. {
  27. clock_t t;
  28. t=clock();
  29. return ((double)t)/CLOCKS_PER_SEC;
  30. }
  31. #else
  32. #ifndef NO_TIMER
  33. #include <sys/types.h>
  34. #include <sys/times.h>
  35. #include <sys/time.h>
  36. #include <unistd.h>
  37. #endif
  38. /*! \brief Timer function
  39. */
  40. double SuperLU_timer_()
  41. {
  42. #ifdef NO_TIMER
  43. /* no sys/times.h on WIN32 */
  44. double tmp;
  45. tmp = 0.0;
  46. /* return (double)(tmp) / CLK_TCK;*/
  47. return 0.0;
  48. #else
  49. struct tms use;
  50. double tmp;
  51. int clocks_per_sec = sysconf(_SC_CLK_TCK);
  52. times ( &use );
  53. tmp = use.tms_utime;
  54. tmp += use.tms_stime;
  55. return (double)(tmp) / clocks_per_sec;
  56. #endif
  57. }
  58. #endif