/* ------------------------------------------------------------------- */
/* 6. C<<1 va_list based library functions, updated 2008-01-22 by xCh. */
/* ------------------------------------------------------------------- */
-#define _ECHO void _cll1_print(int nl,char *s, ... ) { va_list ap; for(va_start(ap,s);s!=(void *)&_cll1_print;s=va_arg(ap,char *)) fputs(s?s:"",stdout); va_end(ap); if(nl) putchar('\n');}
+#define _ECHO void _cll1_print(int p,char *s, ... ) { int p2=0; va_list ap; for(va_start(ap,s);s!=(void *)&_cll1_print;s=va_arg(ap,char *)) { if(p) {if(p2) putchar(' '); else p2=1;} fputs(s?s:"",stdout); } va_end(ap); if(p) putchar('\n');}
#define print(...) _cll1_print(1,__VA_ARGS__,(void *)&_cll1_print)
#define echo(...) _cll1_print(0,__VA_ARGS__,(void *)&_cll1_print)
/* ------------------------------------------------------------------- */
program
{
- echo("Hello ","world",NULL,"! ");
- print("Hello ",NULL,"world","!");
+ echo("Hello ",NULL,"world"," ! ");
+ print("Hello","world",NULL,"!");
}
#include "cll1.h"
-#define RUNS 10000000UL
program
{
- unsigned long i;
- for_range(i,0,RUNS)
- {
+ repeat(10000000)
print("stuff");
- }
- return 0;
}
--- /dev/null
+#include "cll1.h"
+
+program
+{
+ repeat(10000000)
+ print("stuff1","stuff2");
+}
--- /dev/null
+#include <stdio.h>
+
+#define RUNS 10000000UL
+int main (void)
+{
+ unsigned long i;
+ for (i=0;i<RUNS;i++) {
+ fputs("stuff1",stdout);
+ fputs(" ",stdout);
+ fputs("stuff2",stdout);
+ fputs("\n",stdout);
+ }
+ return 0;
+}
--- /dev/null
+#!/usr/bin/perl
+
+my $i=0;
+for ($i=0;$i<10000000;$i++)
+{
+ print ("stuff1"," ","stuff2","\n");
+}
--- /dev/null
+#!/usr/bin/python
+
+for i in range(1,10000000):
+ print "stuff1","stuff2"
+
--- /dev/null
+#include <stdio.h>
+
+#define RUNS 10000000UL
+int main (void)
+{
+ unsigned long i;
+ for (i=0;i<RUNS;i++) {
+ printf("%s %s\n","stuff2","stuff2");
+ }
+ return 0;
+}
#!/bin/sh
-make cll1-print
-make printf
-make puts
-make fputs
clear
+
cat print.py
echo "Running..."
time ./print.py > /dev/null
+
cat print.pl
echo "Running..."
time ./print.pl > /dev/null
+
cat cll1-print.c
+echo "Compiling..."
+time make cll1-print
echo "Running..."
time ./cll1-print > /dev/null
+
cat printf.c
+echo "Compiling..."
+time make printf
echo "Running..."
time ./printf > /dev/null
+
cat puts.c
+echo "Compiling..."
+time make puts
echo "Running..."
time ./puts > /dev/null
+
cat fputs.c
+echo "Compiling..."
+make fputs
echo "Running..."
time ./fputs > /dev/null
--- /dev/null
+#!/bin/sh
+clear
+
+cat print2.py
+echo "Running..."
+time ./print2.py > /dev/null
+
+cat print2.pl
+echo "Running..."
+time ./print2.pl > /dev/null
+
+cat cll1-print2.c
+echo "Compiling..."
+time make cll1-print2
+echo "Running..."
+time ./cll1-print2 > /dev/null
+
+cat printf2.c
+echo "Compiling..."
+time make printf2
+echo "Running..."
+time ./printf2 > /dev/null
+
+cat fputs2.c
+echo "Compiling..."
+make fputs2
+echo "Running..."
+time ./fputs2 > /dev/null
--- /dev/null
+\e[H\e[2J#!/usr/bin/python
+
+for i in range(1,10000000):
+ print "stuff"
+
+Running...
+8.56user 0.20system 0:08.82elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+39997minor)pagefaults 0swaps
+#!/usr/bin/perl
+
+my $i=0;
+for ($i=0;$i<10000000;$i++)
+{
+ print ("stuff");
+}
+
+Running...
+2.51user 0.03system 0:02.63elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+424minor)pagefaults 0swaps
+#include "cll1.h"
+
+program
+{
+ repeat(10000000)
+ print("stuff");
+}
+Compiling...
+cc cll1-print.c -o cll1-print
+0.05user 0.02system 0:00.08elapsed 89%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+3905minor)pagefaults 0swaps
+Running...
+0.98user 0.02system 0:01.01elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+131minor)pagefaults 0swaps
+#include <stdio.h>
+
+#define RUNS 10000000UL
+int main (void)
+{
+unsigned long i;
+for (i=0;i<RUNS;i++) {
+printf("stuff\n");
+}
+return 0;
+}
+Compiling...
+cc printf.c -o printf
+0.04user 0.01system 0:00.06elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+3737minor)pagefaults 0swaps
+Running...
+0.60user 0.02system 0:00.64elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+116minor)pagefaults 0swaps
+#include <stdio.h>
+
+#define RUNS 10000000UL
+int main (void)
+{
+unsigned long i;
+for (i=0;i<RUNS;i++) {
+puts("stuff");
+}
+return 0;
+}
+Compiling...
+cc puts.c -o puts
+0.04user 0.01system 0:00.05elapsed 103%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+3734minor)pagefaults 0swaps
+Running...
+0.61user 0.00system 0:00.64elapsed 95%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+115minor)pagefaults 0swaps
+#include <stdio.h>
+
+#define RUNS 10000000UL
+int main (void)
+{
+unsigned long i;
+for (i=0;i<RUNS;i++) {
+fputs("stuff\n",stdout);
+}
+return 0;
+}
+Compiling...
+cc fputs.c -o fputs
+Running...
+0.56user 0.00system 0:00.68elapsed 82%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+115minor)pagefaults 0swaps
--- /dev/null
+\e[H\e[2J#!/usr/bin/python
+
+for i in range(1,10000000):
+ print "stuff1","stuff2"
+
+Running...
+13.31user 0.16system 0:13.47elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+39997minor)pagefaults 0swaps
+#!/usr/bin/perl
+
+my $i=0;
+for ($i=0;$i<10000000;$i++)
+{
+ print ("stuff1"," ","stuff2","\n");
+}
+Running...
+5.68user 0.00system 0:05.70elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+425minor)pagefaults 0swaps
+#include "cll1.h"
+
+program
+{
+ repeat(10000000)
+ print("stuff1","stuff2");
+}
+Compiling...
+cc cll1-print2.c -o cll1-print2
+0.06user 0.01system 0:00.07elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+3904minor)pagefaults 0swaps
+Running...
+1.95user 0.01system 0:01.96elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+130minor)pagefaults 0swaps
+#include <stdio.h>
+
+#define RUNS 10000000UL
+int main (void)
+{
+ unsigned long i;
+ for (i=0;i<RUNS;i++) {
+ printf("%s %s\n","stuff2","stuff2");
+ }
+ return 0;
+}
+Compiling...
+cc printf2.c -o printf2
+0.05user 0.01system 0:00.06elapsed 106%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+3735minor)pagefaults 0swaps
+Running...
+2.89user 0.00system 0:02.90elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+121minor)pagefaults 0swaps
+#include <stdio.h>
+
+#define RUNS 10000000UL
+int main (void)
+{
+ unsigned long i;
+ for (i=0;i<RUNS;i++) {
+ fputs("stuff1",stdout);
+ fputs(" ",stdout);
+ fputs("stuff2",stdout);
+ fputs("\n",stdout);
+ }
+ return 0;
+}
+Compiling...
+cc fputs2.c -o fputs2
+Running...
+1.52user 0.00system 0:01.53elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
+0inputs+0outputs (0major+115minor)pagefaults 0swaps