Created
May 24, 2013 03:05
-
-
Save aji/5641036 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
int main(int argc, char *argv[]) | |
{ | |
char buf[512]; | |
char *args[3] = { argv[0], NULL, NULL }; | |
int x = (argc > 1 ? atoi(argv[1]) : 0) + 1; | |
if (x == 10000) | |
return puts("done") && 0; | |
snprintf(buf, 512, "%d", x); | |
args[1] = buf; | |
execv(args[0], args); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
int main(int argc, char *argv[]) | |
{ | |
char buf[512] = ""; | |
int x; | |
top: | |
x = (buf[0] ? atoi(buf) : 0) + 1; | |
if (x == 10000) | |
return puts("done") && 0; | |
snprintf(buf, 512, "%d", x); | |
goto top; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
theta ~/work/sandbox/sexec$ time ./sexec | |
done | |
real 0m4.834s | |
user 0m1.207s | |
sys 0m3.540s | |
theta ~/work/sandbox/sexec$ time ./sprint | |
done | |
real 0m0.005s | |
user 0m0.003s | |
sys 0m0.000s | |
theta ~/work/sandbox/sexec$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment