You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/07/20 12:28:22 UTC

[GitHub] [incubator-nuttx] acassis edited a comment on pull request #4186: libc: Implement times function

acassis edited a comment on pull request #4186:
URL: https://github.com/apache/incubator-nuttx/pull/4186#issuecomment-883350583


   Hi @xiaoxiang781216 why aren't the fields of tms filled?
   What happens when you run this example:
   ```
   #include <sys/times.h>
   #include <stdio.h>
   ...
   void start_clock(void);
   void end_clock(char *msg);
   ...
   static clock_t st_time;
   static clock_t en_time;
   static struct tms st_cpu;
   static struct tms en_cpu;
   ...
   void
   start_clock()
   {
       st_time = times(&st_cpu);
   }
   
   
   /* This example assumes that the result of each subtraction
      is within the range of values that can be represented in
      an integer type. */
   void
   end_clock(char *msg)
   {
       en_time = times(&en_cpu);
   
   
       fputs(msg,stdout);
       printf("Real Time: %jd, User Time %jd, System Time %jd\n",
           (intmax_t)(en_time - st_time),
           (intmax_t)(en_cpu.tms_utime - st_cpu.tms_utime),
           (intmax_t)(en_cpu.tms_stime - st_cpu.tms_stime));
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org