'----------------------------------------------------------------------- */
#define push(NODE,HEAD) ( NODE ? ((NODE->__next=HEAD),(HEAD=NODE)) : NULL )
#define pop(NODE,HEAD) ( HEAD ? ((NODE=HEAD->__next),free(HEAD),(HEAD=NODE)) : (NODE=NULL) )
-#define append(NODE,HEAD) { void *N=NODE; /**/ NODE->__next=NULL; for_search(NODE,HEAD,!NODE->__next) { NODE->__next=N; break; } }
-#define remove(NODE,HEAD,EXPR) { void **_D=NULL; /**/ for_search(NODE,HEAD,EXPR) { if(_D)*_D=NODE->__next; else HEAD=NODE->__next; free(NODE); } else _D=(void *)&(NODE->__next); }
+#define append(NODE,HEAD) { void *N=NODE; /* <-' */ NODE->__next=NULL; for_search(NODE,HEAD,!NODE->__next) { NODE->__next=N; break; } }
+#define remove(NODE,HEAD,EXPR) { void **_D=NULL; /* <-' */ for_search(NODE,HEAD,EXPR) { if(_D)*_D=NODE->__next; else HEAD=NODE->__next; free(NODE); } else _D=(void *)&(NODE->__next); }
#define drop(NODE,HEAD) for( NODE=HEAD; NODE || (HEAD=NULL); HEAD=NODE, NODE=NODE->__next, free(HEAD) )
//to do: seek
//to do: store
#define desc_sort_by(K1,K2) (strcasecmp(K1, K2)<0)
#define ascii_by(K1,K2) (strcmp(K1, K2)>0)
#define desc_ascii_by(K1,K2) (strcmp(K1, K2)<0)
-#define insert(NODE,HEAD,EXP,K) { if(HEAD) { void **_L=NULL, *H=HEAD; /**/ for_search(HEAD,H,EXP(HEAD->K,NODE->K)) { if(_L) {*_L=NODE; NODE->__next=HEAD; } else push(NODE,H); break; } else _L=(void *)&(HEAD->__next); if(!HEAD)*_L=NODE; HEAD=H; } else if (NODE) { push(NODE,HEAD); HEAD->__next=NULL; } }
-#define sort(NODE,HEAD,EXP,K) { void *_NEXT; /**/ NODE=HEAD; HEAD=NULL; do { _NEXT=NODE->__next; NODE->__next=NULL; insert(NODE,HEAD,EXP,K); NODE=_NEXT; } while(_NEXT); }
+#define insert(NODE,HEAD,EXP,K) { if(HEAD) { void **_L=NULL, *H=HEAD; /* <-' */ for_search(HEAD,H,EXP(HEAD->K,NODE->K)) { if(_L) {*_L=NODE; NODE->__next=HEAD; } else push(NODE,H); break; } else _L=(void *)&(HEAD->__next); if(!HEAD)*_L=NODE; HEAD=H; } else if (NODE) { push(NODE,HEAD); HEAD->__next=NULL; } }
+#define sort(NODE,HEAD,EXP,K) { void *_NEXT; /* <-' */ NODE=HEAD; HEAD=NULL; do { _NEXT=NODE->__next; NODE->__next=NULL; insert(NODE,HEAD,EXP,K); NODE=_NEXT; } while(_NEXT); }
/* .----------------------------------------------------------------------.
/ 7. C<<1 builtin iterators and conditionals, updated 2008-01-26 xCh.
'----------------------------------------------------------------------- */
#define construct_interface(MTYPE,...) _construct_##_##MTYPE##_##_ARG1(__VA_ARGS__)((void *)__get_##_##MTYPE##_##__VA_ARGS__)
#define get_object(TYPE,...) (struct TYPE *)_cll1_allocate_object(sizeof(struct TYPE), __VA_ARGS__)
#define construct_object(TYPE,...)
-//#define _(OBJECT,...) (_ASSERT(OBJECT),/**/(*(OBJECT->interface->_ARG1(__VA_ARGS__,)))/**/(OBJECT,OBJECT->interface->__VA_ARGS__)/**/)
+//#define _(OBJECT,...) ( _ASSERT(OBJECT), (*( OBJECT->interface->_ARG1(__VA_ARGS__,) )) ( OBJECT,OBJECT->interface->__VA_ARGS__ ) )
+//#define __(OBJECT,...) ( _ASSERT(OBJECT), (*( __cll1_seekmethod(OBJECT->interface,_ARG1(__VA_ARGS__,)) )) ( OBJECT,OBJECT->interface->__VA_ARGS__ ) )
/* .----------------------------------------------------------------------.
/ 9. implementation of C<<1 library functions, updated 2008-01-26 xCh.
'----------------------------------------------------------------------- */
#define _MALLOC void *_cll1_malloc(size_t size,...) { /*temporary solution*/ return malloc(size); }
-#define _CLL1_FPRINT(IOSTREAM,LASTARG) { int p2=0;char *ofs=coalesce(OFS,"\0");va_list ap; /**/ for(va_start(ap,s);s!=LASTARG;s=va_arg(ap,char *)) { if(p2 && *ofs) fputs(ofs,IOSTREAM); else p2=1; fputs(coalesce(s,NIL),IOSTREAM); } va_end(ap); if(EOL && *EOL) fputs(EOL,IOSTREAM); }
+#define _CLL1_FPRINT(IOSTREAM,LASTARG) { int ofs=0; va_list ap; /* <-' */ for(va_start(ap,s);s!=LASTARG;s=va_arg(ap,char *)) { if(ofs)fputs(OFS,IOSTREAM);else ofs=1;/**/fputs(coalesce(s,NIL),IOSTREAM); } va_end(ap); fputs(EOL,IOSTREAM); }
#define _PRINT void _cll1_print(char *s,...) _CLL1_FPRINT(stdout,(void *)&_cll1_print)
#define _FPRINT void _cll1_fprint(FILE *f,char *s,...) _CLL1_FPRINT(f,(void *)&_cll1_fprint)
-#define _CLL1_FECHO(IOSTREAM,LASTARG) { va_list ap; /**/ for(va_start(ap,s);s!=LASTARG;s=va_arg(ap,char *)) fputs(coalesce(s,NIL),IOSTREAM); va_end(ap); }
+#define _CLL1_FECHO(IOSTREAM,LASTARG) { va_list ap; /* <-' */ for(va_start(ap,s);s!=LASTARG;s=va_arg(ap,char *)) fputs(coalesce(s,NIL),IOSTREAM); va_end(ap); }
#define _ECHO void _cll1_echo(char *s,...) _CLL1_FECHO(stdout,(void *)&_cll1_echo)
#define _FECHO void _cll1_fecho(FILE *f,char *s,...) _CLL1_FECHO(f,(void *)&_cll1_fecho)
-#define _IT_INTS int _cll1_it_ints(int i, int n, ...) { int j=0;va_list ap; /**/ va_start(ap,n); while(n>=0 && j++<i) n=va_arg(ap,int); return n; }
-#define _IT_STRS char *_cll1_it_strs(int i, char *s, ...) { int j=0;va_list ap; /**/ va_start(ap,s); while(s!=(void *)&_cll1_it_strs && j++<i) s=va_arg(ap,char *); return s; }
+#define _IT_INTS int _cll1_it_ints(int i, int n, ...) { int j=0;va_list ap; /* <-' */ va_start(ap,n); while(n>=0 && j++<i) n=va_arg(ap,int); return n; }
+#define _IT_STRS char *_cll1_it_strs(int i, char *s, ...) { int j=0;va_list ap; /* <-' */ va_start(ap,s); while(s!=(void *)&_cll1_it_strs && j++<i) s=va_arg(ap,char *); return s; }
/* .----------------------------------------------------------------------.
/ 10. C<<1 globals and private macros, updated 2008-01-27 by xCh.
'----------------------------------------------------------------------- */
print("* coalesce():");
print("We can",coalesce("print","everything"),coalesce(NULL,"everything"),"safely.");
print("* OFS");
+ OFS="";
+ EOL="";
+ print("We","Can","Print","Without","Spaces","BetweenArgs.");
OFS=":";
- print("We","can","customize","print");
+ print("We","can","customize","print.");
OFS="...";
EOL="<--\n";
+ print("");
print("* MAYBE ?");
repeat(4) print((MAYBE ? "Hello" : "Hi"), (MAYBE ? "world" : "friend"), (MAYBE ? "!" : "?"));
print("* WHOKNOWS ?");
--- /dev/null
+#include "cll1.h"
+
+program
+{
+ unsigned long i;
+ for_range(i,1,10000000)
+ echo("stuff\n");
+}
int main()
{
unsigned long i;
- for (i=0;i<RUNS;i++) {
- std::cout << "stuff\n";
+ for (i=0;i<RUNS;i++)
+ {
+ std::cout << "stuff\n";
}
return 0;
}
#define RUNS 10000000UL
int main (void)
{
-unsigned long i;
-for (i=0;i<RUNS;i++) {
-fputs("stuff\n",stdout);
-}
-return 0;
+ unsigned long i;
+ for (i=0;i<RUNS;i++)
+ {
+ fputs("stuff\n",stdout);
+ }
+ return 0;
}
#!/usr/bin/ruby
10000000.times { print "stuff","\n" }
+
#!/usr/bin/ruby
10000000.times { print "stuff1"," ","stuff2","\n" }
+
#define RUNS 10000000UL
int main (void)
{
-unsigned long i;
-for (i=0;i<RUNS;i++) {
-printf("stuff\n");
-}
-return 0;
+ unsigned long i;
+ for (i=0;i<RUNS;i++)
+ {
+ printf("stuff\n");
+ }
+ return 0;
}
int main (void)
{
unsigned long i;
- for (i=0;i<RUNS;i++) {
+ for (i=0;i<RUNS;i++)
+ {
printf("%s %s\n","stuff2","stuff2");
}
return 0;
#define RUNS 10000000UL
int main (void)
{
-unsigned long i;
-for (i=0;i<RUNS;i++) {
-puts("stuff");
-}
-return 0;
+ unsigned long i;
+ for (i=0;i<RUNS;i++)
+ {
+ puts("stuff");
+ }
+ return 0;
}
-#!/bin/sh
+#!/bin/bash
+echo "------------------------------------------------------------- Ruby"
cat print.rb
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./print.rb > /dev/null
-echo
+time ./print.rb > /dev/null
+echo "--------------------------------------------------- Python - range"
cat print.py
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./print.py > /dev/null
-echo
+time ./print.py > /dev/null
+echo "-------------------------------------------------- Python - xrange"
cat xrange.py
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./xrange.py > /dev/null
-echo
+time ./xrange.py > /dev/null
+echo "------------------------------------------------------------ PHP 5"
cat echo.php
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./echo.php > /dev/null
-echo
+time ./echo.php > /dev/null
+echo "-------------------------------------------------- C - gcc - write"
cat write.c
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" gcc -O2 write.c -o write
+time gcc -O2 write.c -o write
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./write > /dev/null
+time ./write > /dev/null
+echo "------------------------------------------------------------- Perl"
cat print.pl
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./print.pl > /dev/null
-echo
+time ./print.pl > /dev/null
+echo "----------------------------------------------- C<<1 - gcc - print"
+cat cll1-print.c
+echo -n "Compiling..."
+time gcc -O2 cll1-print.c -o cll1-print
+echo -n "Running..."
+time ./cll1-print > /dev/null
+
+echo "---------------------------------------------- C - g++ - std::cout"
cat cout.cpp
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" g++ -O2 cout.cpp -o cout
+time g++ -O2 cout.cpp -o cout
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./cout > /dev/null
+time ./cout > /dev/null
-echo
-cat cll1-print.c
+#echo "----------------------------------------------- C<<1 - tcc - print"
+#cat cll1-print.c
+#echo -n "Compiling..."
+#time tcc -O2 cll1-print.c -o cll1-print
+#echo -n "Running..."
+#time ./cll1-print > /dev/null
+#
+#echo "------------------------------------------------- C - tcc - printf"
+#cat printf.c
+#echo -n "Compiling..."
+#time tcc -O2 printf.c -o printf
+#echo -n "Running..."
+#time ./printf > /dev/null
+#
+#echo "--------------------------------------------------- C - tcc - puts"
+#cat puts.c
+#echo -n "Compiling..."
+#time tcc -O2 puts.c -o puts
+#echo -n "Running..."
+#time ./puts > /dev/null
+#
+#echo "-------------------------------------------------- C - tcc - fputs"
+#cat fputs.c
+#echo -n "Compiling..."
+#time tcc -O2 fputs.c -o fputs
+#echo -n "Running..."
+#time ./fputs > /dev/null
+#
+#echo "------------------------------------------------- C - tcc - fwrite"
+#cat fwrite.c
+#echo -n "Compiling..."
+#time tcc -O2 fwrite.c -o fwrite
+#echo -n "Running..."
+#time ./fwrite > /dev/null
+#
+
+echo "-----------------------------------------------= C<<1 - gcc - echo"
+cat cll1-echo.c
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" gcc -O2 cll1-print.c -o cll1-print
+time gcc -O2 cll1-echo.c -o cll1-echo
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./cll1-print > /dev/null
-echo
+time ./cll1-echo > /dev/null
+echo "------------------------------------------------- C - gcc - printf"
cat printf.c
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" gcc -O2 printf.c -o printf
+time gcc -O2 printf.c -o printf
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./printf > /dev/null
-echo
+time ./printf > /dev/null
+echo "--------------------------------------------------- C - gcc - puts"
cat puts.c
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" gcc -O2 puts.c -o puts
+time gcc -O2 puts.c -o puts
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./puts > /dev/null
-echo
+time ./puts > /dev/null
-cat fputs.c
+echo "------------------------------------------------- C - gcc - fwrite"
+cat fwrite.c
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" gcc -O2 fputs.c -o fputs
+time gcc -O2 fwrite.c -o fwrite
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./fputs > /dev/null
-echo
+time ./fwrite > /dev/null
-cat fwrite.c
+echo "-------------------------------------------------- C - gcc - fputs"
+cat fputs.c
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" gcc -O2 fwrite.c -o fwrite
+time gcc -O2 fputs.c -o fputs
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./fwrite > /dev/null
+time ./fputs > /dev/null
-#!/bin/sh
+#!/bin/bash
+echo "------------------------------------------------------------- Ruby"
cat print2.rb
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./print2.rb > /dev/null
+time ./print2.rb > /dev/null
echo
+echo "--------------------------------------------------- Python - range"
cat print2.py
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./print2.py > /dev/null
+time ./print2.py > /dev/null
echo
+echo "-------------------------------------------------- Python - xrange"
cat xrange2.py
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./xrange2.py > /dev/null
+time ./xrange2.py > /dev/null
echo
+echo "------------------------------------------------------------ PHP 5"
cat echo2.php
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./echo2.php > /dev/null
+time -f "%E total, %U user, %S sys" ./echo2.php > /dev/null
echo
+echo "-------------------------------------------------- C - gcc - write"
cat write2.c
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" gcc -O2 write2.c -o write2
+time gcc -O2 write2.c -o write2
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./write2 > /dev/null
+time ./write2 > /dev/null
echo
+echo "---------------------------------------------- C - g++ - std::cout"
cat cout2.cpp
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" g++ -O2 cout2.cpp -o cout2
+time g++ -O2 cout2.cpp -o cout2
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./cout2 > /dev/null
+time ./cout2 > /dev/null
echo
+echo "------------------------------------------------------------- Perl"
cat print2.pl
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./print2.pl > /dev/null
+time -f "%E total, %U user, %S sys" ./print2.pl > /dev/null
echo
+#echo "------------------------------------------------- C - tcc - printf"
+#cat printf2.c
+#echo -n "Compiling..."
+#time tcc -O2 printf2.c -o printf2
+#echo -n "Running..."
+#time ./printf2 > /dev/null
+#echo
+#
+#echo "------------------------------------------------- C - tcc - fwrite"
+#cat fwrite2.c
+#echo -n "Compiling..."
+#time tcc -O2 fwrite2.c -o fwrite2
+#echo -n "Running..."
+#time ./fwrite2 > /dev/null
+#echo
+#
+#echo "----------------------------------------------- C<<1 - tcc - print"
+#cat cll1-print2.c
+#echo -n "Compiling..."
+#time tcc -O2 cll1-print2.c -o cll1-print2
+#echo -n "Running..."
+#time ./cll1-print2 > /dev/null
+#echo
+#
+#echo "-------------------------------------------------- C - tcc - fputs"
+#cat fputs2.c
+#echo -n "Compiling..."
+#time tcc -O2 fputs2.c -o fputs2
+#echo -n "Running..."
+#time ./fputs2 > /dev/null
+#echo
+#
+echo "------------------------------------------------- C - gcc - printf"
cat printf2.c
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" gcc -O2 printf2.c -o printf2
+time gcc -O2 printf2.c -o printf2
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./printf2 > /dev/null
+time ./printf2 > /dev/null
echo
-
-cat cll1-print2.c
+echo "------------------------------------------------- C - gcc - fwrite"
+cat fwrite2.c
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" gcc -O2 cll1-print2.c -o cll1-print2
+time gcc -O2 fwrite2.c -o fwrite2
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./cll1-print2 > /dev/null
+time ./fwrite2 > /dev/null
echo
-cat fputs2.c
+echo "----------------------------------------------- C<<1 - gcc - print"
+cat cll1-print2.c
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" gcc -O2 fputs2.c -o fputs2
+time gcc -O2 cll1-print2.c -o cll1-print2
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./fputs2 > /dev/null
+time ./cll1-print2 > /dev/null
echo
-cat fwrite2.c
+echo "-------------------------------------------------- C - gcc - fputs"
+cat fputs2.c
echo -n "Compiling..."
-time -f "%E total, %U user, %S sys, %F page faults" gcc -O2 fwrite2.c -o fwrite2
+time gcc -O2 fputs2.c -o fputs2
echo -n "Running..."
-time -f "%E total, %U user, %S sys, %F page faults" ./fwrite2 > /dev/null
+time ./fputs2 > /dev/null
echo
+------------------------------------------------------------- Ruby
#!/usr/bin/ruby
10000000.times { print "stuff","\n" }
-Running...0:15.62 total, 14.06 user, 1.55 sys, 0 page faults
+Running...
+real 0m16.104s
+user 0m14.353s
+sys 0m1.412s
+--------------------------------------------------- Python - range
#!/usr/bin/python
for i in range(1,10000000):
print "stuff"
-Running...0:08.64 total, 8.43 user, 0.21 sys, 0 page faults
-
+Running...
+real 0m8.661s
+user 0m8.465s
+sys 0m0.168s
+-------------------------------------------------- Python - xrange
#!/usr/bin/python
for i in xrange(1,10000000):
print "stuff"
-Running...0:08.19 total, 8.17 user, 0.00 sys, 0 page faults
-
+Running...
+real 0m8.480s
+user 0m8.433s
+sys 0m0.016s
+------------------------------------------------------------ PHP 5
#!/usr/bin/php5 -q
<?php
for ( $i=0; $i<10000000; $i++ )
echo "stuff1\n";
}
?>
-Running...0:07.08 total, 5.00 user, 2.07 sys, 0 page faults
-
+Running...
+real 0m7.098s
+user 0m5.048s
+sys 0m2.024s
+-------------------------------------------------- C - gcc - write
#include <string.h>
#define RUNS 10000000UL
char *s1="stuff\n";
int l1=strlen(s1);
-for (i=0;i<RUNS;i++)
-{
- write(1,s1,l1);
-}
-return 0;
+ for (i=0;i<RUNS;i++)
+ {
+ write(1,s1,l1);
+ }
+ return 0;
}
-Compiling...0:00.06 total, 0.05 user, 0.00 sys, 0 page faults
-Running...0:02.90 total, 0.90 user, 2.00 sys, 0 page faults
+Compiling...
+real 0m0.061s
+user 0m0.048s
+sys 0m0.012s
+Running...
+real 0m2.906s
+user 0m0.848s
+sys 0m2.028s
+------------------------------------------------------------- Perl
#!/usr/bin/perl
my $i=0;
print ("stuff");
}
-Running...0:02.44 total, 2.44 user, 0.00 sys, 0 page faults
+Running...
+real 0m2.515s
+user 0m2.484s
+sys 0m0.008s
+----------------------------------------------- C<<1 - gcc - print
+#include "cll1.h"
+program
+{
+ repeat(10000000)
+ print("stuff");
+}
+Compiling...
+real 0m0.121s
+user 0m0.112s
+sys 0m0.008s
+Running...
+real 0m1.249s
+user 0m1.240s
+sys 0m0.004s
+---------------------------------------------- C - g++ - std::cout
#include <iostream>
#define RUNS 10000000UL
int main()
{
unsigned long i;
- for (i=0;i<RUNS;i++) {
- std::cout << "stuff\n";
+ for (i=0;i<RUNS;i++)
+ {
+ std::cout << "stuff\n";
}
return 0;
}
-Compiling...0:00.37 total, 0.35 user, 0.01 sys, 0 page faults
-Running...0:00.99 total, 0.99 user, 0.00 sys, 0 page faults
-
+Compiling...
+real 0m0.362s
+user 0m0.320s
+sys 0m0.036s
+Running...
+real 0m0.990s
+user 0m0.984s
+sys 0m0.004s
+-----------------------------------------------= C<<1 - gcc - echo
#include "cll1.h"
program
{
- repeat(10000000)
- print("stuff");
-}
-Compiling...0:00.12 total, 0.12 user, 0.00 sys, 0 page faults
-Running...0:01.23 total, 1.23 user, 0.00 sys, 0 page faults
-
-#include <stdio.h>
-
-#define RUNS 10000000UL
-int main (void)
-{
-unsigned long i;
-for (i=0;i<RUNS;i++) {
-printf("stuff\n");
-}
-return 0;
+ unsigned long i;
+ for_range(i,1,10000000)
+ echo("stuff\n");
}
-Compiling...0:00.05 total, 0.04 user, 0.02 sys, 0 page faults
-Running...0:00.62 total, 0.62 user, 0.00 sys, 0 page faults
-
+Compiling...
+real 0m0.117s
+user 0m0.100s
+sys 0m0.008s
+Running...
+real 0m0.757s
+user 0m0.744s
+sys 0m0.000s
+------------------------------------------------- C - gcc - printf
#include <stdio.h>
#define RUNS 10000000UL
int main (void)
{
-unsigned long i;
-for (i=0;i<RUNS;i++) {
-puts("stuff");
-}
-return 0;
+ unsigned long i;
+ for (i=0;i<RUNS;i++)
+ {
+ printf("stuff\n");
+ }
+ return 0;
}
-Compiling...0:00.05 total, 0.04 user, 0.01 sys, 0 page faults
-Running...0:00.62 total, 0.62 user, 0.00 sys, 0 page faults
-
+Compiling...
+real 0m0.067s
+user 0m0.040s
+sys 0m0.024s
+Running...
+real 0m0.630s
+user 0m0.608s
+sys 0m0.012s
+--------------------------------------------------- C - gcc - puts
#include <stdio.h>
#define RUNS 10000000UL
int main (void)
{
-unsigned long i;
-for (i=0;i<RUNS;i++) {
-fputs("stuff\n",stdout);
-}
-return 0;
+ unsigned long i;
+ for (i=0;i<RUNS;i++)
+ {
+ puts("stuff");
+ }
+ return 0;
}
-Compiling...0:00.06 total, 0.05 user, 0.00 sys, 0 page faults
-Running...0:00.56 total, 0.56 user, 0.00 sys, 0 page faults
-
+Compiling...
+real 0m0.058s
+user 0m0.036s
+sys 0m0.024s
+Running...
+real 0m0.633s
+user 0m0.632s
+sys 0m0.000s
+------------------------------------------------- C - gcc - fwrite
#include <stdio.h>
#include <string.h>
}
return 0;
}
-Compiling...0:00.06 total, 0.05 user, 0.01 sys, 0 page faults
-Running...0:00.53 total, 0.53 user, 0.00 sys, 0 page faults
+Compiling...
+real 0m0.137s
+user 0m0.060s
+sys 0m0.008s
+Running...
+real 0m0.555s
+user 0m0.548s
+sys 0m0.004s
+-------------------------------------------------- C - gcc - fputs
+#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...
+real 0m0.058s
+user 0m0.040s
+sys 0m0.016s
+Running...
+real 0m0.551s
+user 0m0.548s
+sys 0m0.004s
+------------------------------------------------------------- Ruby
#!/usr/bin/ruby
10000000.times { print "stuff1"," ","stuff2","\n" }
-Running...0:23.81 total, 22.24 user, 1.55 sys, 0 page faults
+Running...
+real 0m24.569s
+user 0m23.113s
+sys 0m1.420s
+
+--------------------------------------------------- Python - range
#!/usr/bin/python
for i in range(1,10000000):
print "stuff1","stuff2"
-Running...0:13.72 total, 13.54 user, 0.18 sys, 0 page faults
+Running...
+real 0m13.571s
+user 0m13.369s
+sys 0m0.200s
+-------------------------------------------------- Python - xrange
#!/usr/bin/python
for i in xrange(1,10000000):
print "stuff1","stuff2"
-Running...0:13.39 total, 13.38 user, 0.00 sys, 0 page faults
+Running...
+real 0m13.118s
+user 0m13.105s
+sys 0m0.012s
+------------------------------------------------------------ PHP 5
#!/usr/bin/php5 -q
<?php
for ( $i=0; $i<10000000; $i++ )
echo "stuff1"." "."stuff2"."\n";
}
?>
-Running...0:11.89 total, 9.90 user, 1.98 sys, 0 page faults
+Running..../test-performance2.sh: line 24: -f: command not found
-#include <stdio.h>
+real 0m0.001s
+user 0m0.000s
+sys 0m0.000s
+
+-------------------------------------------------- C - gcc - write
#include <string.h>
#define RUNS 10000000UL
}
return 0;
}
-Compiling...0:00.06 total, 0.04 user, 0.02 sys, 0 page faults
-Running...0:11.79 total, 2.92 user, 8.85 sys, 0 page faults
-
+Compiling...
+real 0m0.063s
+user 0m0.044s
+sys 0m0.016s
+Running...
+real 0m11.514s
+user 0m3.572s
+sys 0m7.928s
+
+---------------------------------------------- C - g++ - std::cout
#include <iostream>
#define RUNS 10000000UL
}
return 0;
}
-Compiling...0:00.37 total, 0.35 user, 0.02 sys, 0 page faults
-Running...0:08.00 total, 5.91 user, 2.08 sys, 0 page faults
-
+Compiling...
+real 0m0.367s
+user 0m0.336s
+sys 0m0.024s
+Running...
+real 0m8.012s
+user 0m6.092s
+sys 0m1.812s
+
+------------------------------------------------------------- Perl
#!/usr/bin/perl
my $i=0;
{
print ("stuff1"," ","stuff2","\n");
}
-Running...0:05.69 total, 5.68 user, 0.00 sys, 0 page faults
+Running..../test-performance2.sh: line 46: -f: command not found
+
+real 0m0.001s
+user 0m0.000s
+sys 0m0.004s
+------------------------------------------------- C - gcc - printf
#include <stdio.h>
#define RUNS 10000000UL
int main (void)
{
unsigned long i;
- for (i=0;i<RUNS;i++) {
+ for (i=0;i<RUNS;i++)
+ {
printf("%s %s\n","stuff2","stuff2");
}
return 0;
}
-Compiling...0:00.06 total, 0.04 user, 0.01 sys, 0 page faults
-Running...0:02.80 total, 2.80 user, 0.00 sys, 0 page faults
+Compiling...
+real 0m0.098s
+user 0m0.080s
+sys 0m0.016s
+Running...
+real 0m2.818s
+user 0m2.820s
+sys 0m0.000s
+
+------------------------------------------------- C - gcc - fwrite
+#include <stdio.h>
+#include <string.h>
+#define RUNS 10000000UL
+int main (void)
+{
+ unsigned long i;
+ char *s1="stuff1";
+ char *s2="stuff2";
+ int l1=strlen(s1);
+ int l2=strlen(s2);
+
+ for (i=0;i<RUNS;i++)
+ {
+ fwrite(s1,l1,1,stdout);
+ fwrite(" ",1,1,stdout);
+ fwrite(s2,l2,1,stdout);
+ fwrite("\n",1,1,stdout);
+ }
+ return 0;
+}
+Compiling...
+real 0m0.070s
+user 0m0.052s
+sys 0m0.016s
+Running...
+real 0m2.665s
+user 0m2.624s
+sys 0m0.012s
+
+----------------------------------------------- C<<1 - gcc - print
#include "cll1.h"
program
repeat(10000000)
print("stuff1","stuff2");
}
-Compiling...0:00.13 total, 0.11 user, 0.01 sys, 0 page faults
-Running...0:02.47 total, 2.47 user, 0.00 sys, 0 page faults
-
+Compiling...
+real 0m0.121s
+user 0m0.100s
+sys 0m0.016s
+Running...
+real 0m2.510s
+user 0m2.508s
+sys 0m0.004s
+
+-------------------------------------------------- C - gcc - fputs
#include <stdio.h>
#define RUNS 10000000UL
}
return 0;
}
-Compiling...0:00.06 total, 0.04 user, 0.02 sys, 0 page faults
-Running...0:01.51 total, 1.50 user, 0.00 sys, 0 page faults
-
-#include <stdio.h>
-#include <string.h>
-
-#define RUNS 10000000UL
-int main (void)
-{
- unsigned long i;
- char *s1="stuff1";
- char *s2="stuff2";
- int l1=strlen(s1);
- int l2=strlen(s2);
-
- for (i=0;i<RUNS;i++)
- {
- fwrite(s1,l1,1,stdout);
- fwrite(" ",1,1,stdout);
- fwrite(s2,l2,1,stdout);
- fwrite("\n",1,1,stdout);
- }
- return 0;
-}
-Compiling...0:00.07 total, 0.06 user, 0.01 sys, 0 page faults
-Running...0:02.56 total, 2.56 user, 0.00 sys, 0 page faults
+Compiling...
+real 0m0.060s
+user 0m0.052s
+sys 0m0.008s
+Running...
+real 0m1.567s
+user 0m1.560s
+sys 0m0.008s
char *s1="stuff\n";
int l1=strlen(s1);
-for (i=0;i<RUNS;i++)
-{
- write(1,s1,l1);
-}
-return 0;
+ for (i=0;i<RUNS;i++)
+ {
+ write(1,s1,l1);
+ }
+ return 0;
}
-#include <stdio.h>
#include <string.h>
#define RUNS 10000000UL