From: Chunyu Hu <chuhu@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] Make getrusage04 be able to loop more times
Date: Fri, 9 Jun 2017 03:42:01 -0400 (EDT) [thread overview]
Message-ID: <2050137840.17454791.1496994121958.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20170607151315.GA30168@rei.suse.de>
----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Chunyu Hu" <chuhu@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Wednesday, June 7, 2017 11:13:15 PM
> Subject: Re: [LTP] [PATCH] Make getrusage04 be able to loop more times
>
> Hi!
> > int main(int argc, char *argv[])
> > {
> > struct rusage usage;
> > - unsigned long ulast, udelta, slast, sdelta;
> > + unsigned long ulast, slast, ulasts, slasts;
> > + long udelta, sdelta, udeltas, sdeltas;
> > int i, lc;
> > char msg_string[BUFSIZ];
> >
> > @@ -104,28 +105,33 @@ int main(int argc, char *argv[])
> > tst_count = 0;
> > i = 0;
> > SAFE_GETRUSAGE(cleanup, RUSAGE_THREAD, &usage);
> > - tst_resm(TINFO, "utime:%12luus; stime:%12luus",
> > - usage.ru_utime.tv_usec, usage.ru_stime.tv_usec);
> > + tst_resm(TINFO, "utime:%lus %12luus; stime:%lus %12luus",
> > + usage.ru_utime.tv_sec, usage.ru_utime.tv_usec,
> > + usage.ru_stime.tv_sec, usage.ru_stime.tv_usec);
> > ulast = usage.ru_utime.tv_usec;
> > slast = usage.ru_stime.tv_usec;
> > + ulasts = usage.ru_utime.tv_sec;
> > + slasts = usage.ru_stime.tv_sec;
>
> This is getting ugly. Why not just:
>
> struct timeval ulast = usage.ru_utime;
> struct timeval slast = usage.ru_stime;
OK. I'll post a V2 for this.
>
>
> > while (i < RECORD_MAX) {
> > SAFE_GETRUSAGE(cleanup, RUSAGE_THREAD, &usage);
> > udelta = usage.ru_utime.tv_usec - ulast;
> > sdelta = usage.ru_stime.tv_usec - slast;
> > + udeltas = usage.ru_utime.tv_sec - ulasts;
> > + sdeltas = usage.ru_stime.tv_sec - slasts;
> > if (udelta > 0 || sdelta > 0) {
> > i++;
> > - tst_resm(TINFO, "utime:%12luus; stime:%12luus",
> > - usage.ru_utime.tv_usec,
> > - usage.ru_stime.tv_usec);
> > - if (udelta > 1000 + (BIAS_MAX * factor_nr)) {
> > + tst_resm(TINFO, "utime:%lus %12luus; stime:%lus %12luus",
> > + usage.ru_utime.tv_sec, usage.ru_utime.tv_usec,
> > + usage.ru_stime.tv_sec, usage.ru_stime.tv_usec);
> > + if (udelta > 1000 + (BIAS_MAX * factor_nr) && !udeltas) {
> > sprintf(msg_string,
> > "utime increased > %ldus:",
> > 1000 + BIAS_MAX * factor_nr);
> > tst_brkm(TFAIL, cleanup, msg_string,
> > " delta = %luus", udelta);
> > }
> > - if (sdelta > 1000 + (BIAS_MAX * factor_nr)) {
> > + if (sdelta > 1000 + (BIAS_MAX * factor_nr) && !sdeltas) {
>
> Also why do we skipp the comparsion if seconds has changed?
OK. I'll try to consider second info in V2.
>
> Computing difference for twom timeval structures is not that
> complicated. I can add a helper into include/tst_timer.h if you want.
Do we have? I think we need something like below, not clear
about if this can be done with function or macro ;).
timval_minus(tv1, tv2)
and
timeval_gt
timeval_lt
timeval_e
>
> > sprintf(msg_string,
> > "stime increased > %ldus:",
> > 1000 + BIAS_MAX * factor_nr);
> > @@ -135,6 +141,8 @@ int main(int argc, char *argv[])
> > }
> > ulast = usage.ru_utime.tv_usec;
> > slast = usage.ru_stime.tv_usec;
> > + ulasts = usage.ru_utime.tv_sec;
> > + slasts = usage.ru_stime.tv_sec;
> > busyloop(100000);
> > }
> > }
> > --
> > 1.8.3.1
> >
> >
> > --
> > Mailing list info: https://lists.linux.it/listinfo/ltp
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
--
Regards,
Chunyu Hu
next prev parent reply other threads:[~2017-06-09 7:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 7:28 [LTP] [PATCH] Make getrusage04 be able to loop more times Chunyu Hu
2017-06-07 15:13 ` Cyril Hrubis
2017-06-09 7:42 ` Chunyu Hu [this message]
2017-06-12 15:04 ` Cyril Hrubis
2017-06-13 11:47 ` Chunyu Hu
2017-06-13 12:58 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2050137840.17454791.1496994121958.JavaMail.zimbra@redhat.com \
--to=chuhu@redhat.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox