FreeBSD Bugzilla – Attachment 192723 Details for
Bug 227689
getrusage() still stops counting after a while
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Reproducer
file_227689.txt (text/plain), 975 bytes, created by
ben
on 2018-04-22 10:04:44 UTC
(
hide
)
Description:
Reproducer
Filename:
MIME Type:
Creator:
ben
Created:
2018-04-22 10:04:44 UTC
Size:
975 bytes
patch
obsolete
>#include <iostream> > >#include <assert.h> >#include <sys/resource.h> >#include <unistd.h> > >static float time_used() > { > static rusage prev; > rusage cur; > > assert(getrusage(RUSAGE_SELF, &cur) == 0); > > std::cout << '[' << cur.ru_utime.tv_sec << ", " << cur.ru_utime.tv_usec > << ']'; > > uint64_t diff = (cur.ru_utime.tv_sec - prev.ru_utime.tv_sec) * 1000000 > + cur.ru_utime.tv_usec - prev.ru_utime.tv_usec; > > std::cout << 'T' << diff/1000000. << std::flush; > prev = cur; > > return diff/1000000.; > } > >int main(int argc, const char **argv) > { > int n = 0; > > for ( ; ; ) > { > int k = 0; > for (int i = 0; i < 1e9; ++i) > k += rand(); > std::cout << ' ' << (k & 1) << ' '; > float t = time_used(); > if (t == 0) > { > if (++n == 5) > break; > } > else > n = 0; > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 227689
: 192723