mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-04 10:18:31 +00:00
Make some more fixes
This change deletes mkfifo() so that GNU Make on Windows will work in parallel mode using its pipe-based implementation. There's an example called greenbean2 now, which shows how to build a scalable web server for Windows with 10k+ threads. The accuracy of clock_nanosleep is now significantly improved on Linux.
This commit is contained in:
parent
820c3599ed
commit
3b4dbc9fdd
22 changed files with 870 additions and 330 deletions
|
@ -23,7 +23,7 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
|
||||
#define MAXIMUM 1e8
|
||||
#define MAXIMUM 1e9
|
||||
#define ITERATIONS 10
|
||||
|
||||
void WarmUp(void) {
|
||||
|
@ -33,34 +33,36 @@ void WarmUp(void) {
|
|||
|
||||
void TestSleepRealRelative(void) {
|
||||
printf("\n");
|
||||
printf("testing: clock_nanosleep(CLOCK_REALTIME) with relative timeout\n");
|
||||
printf("testing: clock_nanosleep(CLOCK_REALTIME) with relative "
|
||||
"timeout\n");
|
||||
for (long nanos = 1; nanos < (long)MAXIMUM; nanos *= 2) {
|
||||
struct timespec t1, t2, wf;
|
||||
wf = timespec_fromnanos(nanos);
|
||||
clock_gettime(CLOCK_REALTIME_PRECISE, &t1);
|
||||
clock_gettime(CLOCK_REALTIME, &t1);
|
||||
for (int i = 0; i < ITERATIONS; ++i) {
|
||||
npassert(!clock_nanosleep(CLOCK_REALTIME, 0, &wf, 0));
|
||||
}
|
||||
clock_gettime(CLOCK_REALTIME_PRECISE, &t2);
|
||||
clock_gettime(CLOCK_REALTIME, &t2);
|
||||
long took = timespec_tonanos(timespec_sub(t2, t1)) / ITERATIONS;
|
||||
printf("%,11ld ns sleep took %,11ld ns delta %,11ld ns\n", nanos, took,
|
||||
printf("%,12ld ns sleep took %,12ld ns delta %,12ld ns\n", nanos, took,
|
||||
took - nanos);
|
||||
}
|
||||
}
|
||||
|
||||
void TestSleepMonoRelative(void) {
|
||||
printf("\n");
|
||||
printf("testing: clock_nanosleep(CLOCK_MONOTONIC) with relative timeout\n");
|
||||
printf("testing: clock_nanosleep(CLOCK_MONOTONIC) with relative "
|
||||
"timeout\n");
|
||||
for (long nanos = 1; nanos < (long)MAXIMUM; nanos *= 2) {
|
||||
struct timespec t1, t2, wf;
|
||||
wf = timespec_fromnanos(nanos);
|
||||
clock_gettime(CLOCK_REALTIME_PRECISE, &t1);
|
||||
clock_gettime(CLOCK_REALTIME, &t1);
|
||||
for (int i = 0; i < ITERATIONS; ++i) {
|
||||
npassert(!clock_nanosleep(CLOCK_MONOTONIC, 0, &wf, 0));
|
||||
}
|
||||
clock_gettime(CLOCK_REALTIME_PRECISE, &t2);
|
||||
clock_gettime(CLOCK_REALTIME, &t2);
|
||||
long took = timespec_tonanos(timespec_sub(t2, t1)) / ITERATIONS;
|
||||
printf("%,11ld ns sleep took %,11ld ns delta %,11ld ns\n", nanos, took,
|
||||
printf("%,12ld ns sleep took %,12ld ns delta %,12ld ns\n", nanos, took,
|
||||
took - nanos);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue