cosmopolitan/examples/now.c
Justine Tunney ea0b5d9d1c Get Cosmopolitan into releasable state
A new rollup tool now exists for flattening out the headers in a way
that works better for our purposes than cpp. A lot of the API clutter
has been removed. APIs that aren't a sure thing in terms of general
recommendation are now marked internal.

There's now a smoke test for the amalgamation archive and gigantic
header file. So we can now guarantee you can use this project on the
easiest difficulty setting without the gigantic repository.

A website is being created, which is currently a work in progress:
https://justine.storage.googleapis.com/cosmopolitan/index.html
2020-11-25 08:19:00 -08:00

34 lines
1.3 KiB
C

#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.internal.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;
}