main.c 855 B

123456789101112131415161718192021222324252627282930313233
  1. /****************************************************************************
  2. *
  3. * MODULE: $ETC/current_time_s_ms
  4. * AUTHOR(S): Markus Neteler
  5. * PURPOSE: timer for benchmarking. Prints current time in seconds.milliseconds
  6. *
  7. * COPYRIGHT: (C) 2003 by the GRASS Development Team
  8. *
  9. * This program is free software under the GNU General Public
  10. * License (>=v2). Read the file COPYING that comes with GRASS
  11. * for details.
  12. *
  13. *****************************************************************************/
  14. #include <sys/time.h>
  15. #include <string.h>
  16. #include <stdio.h>
  17. int main()
  18. {
  19. struct timeval t;
  20. if (gettimeofday(&t, NULL) == -1) {
  21. fprintf(stderr, "gettimeofday error");
  22. return 1;
  23. }
  24. fprintf(stdout, "%li.%li\n", t.tv_sec, t.tv_usec);
  25. fflush(stdout);
  26. return 0;
  27. }