mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 10:20:29 +00:00
Initial import
This commit is contained in:
commit
c91b3c5006
14915 changed files with 590219 additions and 0 deletions
34
examples/now.c
Normal file
34
examples/now.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
|
||||
char dtoabuf_[3][32];
|
||||
|
||||
static long double avg;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
long double t2, t1 = nowl();
|
||||
dsleep(0.3);
|
||||
for (;;) {
|
||||
t2 = nowl();
|
||||
printf("%s %s avg=%s\n", g_fmt(dtoabuf_[0], t2),
|
||||
g_fmt(dtoabuf_[1], t2 - t1), g_fmt(dtoabuf_[2], avg));
|
||||
t1 = t2;
|
||||
dsleep(0.3);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue