Invent systemvpe() function

It goes 5x faster than system() and it's safer too.
This commit is contained in:
Justine Tunney 2023-08-09 00:27:55 -07:00
parent 1a5ef5ba13
commit 50394064d7
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
5 changed files with 132 additions and 4 deletions

View file

@ -17,6 +17,7 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/calls.h"
#include "libc/cosmo.h"
#include "libc/dce.h"
#include "libc/mem/gc.h"
#include "libc/mem/gc.internal.h"
@ -243,6 +244,8 @@ int system2(const char *);
BENCH(system, bench) {
testlib_extract("/zip/echo.com", "echo.com", 0755);
EZBENCH2("system cmd", donothing, system("./echo.com hi >/dev/null"));
EZBENCH2("systemvpe cmd", donothing,
systemvpe("./echo.com", (char *[]){"./echo.com", "hi", 0}, 0));
EZBENCH2("cocmd echo", donothing, system("echo hi >/dev/null"));
EZBENCH2("cocmd exit", donothing, system("exit"));
}