From 81088cecf25774a3506a648bd2254079d48f77da Mon Sep 17 00:00:00 2001 From: xchaos Date: Tue, 22 Jan 2008 10:27:35 +0000 Subject: [PATCH] perforamnce test for printing one and two strings in C,C++,C<<1,Perl and Python git-svn-id: https://dev.arachne.cz/repos/cll1h/trunk@22 4bb87942-c103-4e5a-b51c-0ebff58f8515 --- cll1.h | 2 +- demos/hello.c | 4 +- demos/performance/cll1-print.c | 7 +-- demos/performance/cll1-print2.c | 7 +++ demos/performance/fputs2.c | 14 +++++ demos/performance/print2.pl | 7 +++ demos/performance/print2.py | 5 ++ demos/performance/printf2.c | 11 ++++ demos/performance/test-performance | 18 ++++-- demos/performance/test-performance2 | 28 ++++++++++ demos/performance/test-results | 85 +++++++++++++++++++++++++++++ demos/performance/test-results2 | 69 +++++++++++++++++++++++ 12 files changed, 244 insertions(+), 13 deletions(-) create mode 100644 demos/performance/cll1-print2.c create mode 100644 demos/performance/fputs2.c create mode 100755 demos/performance/print2.pl create mode 100755 demos/performance/print2.py create mode 100644 demos/performance/printf2.c create mode 100755 demos/performance/test-performance2 create mode 100644 demos/performance/test-results create mode 100644 demos/performance/test-results2 diff --git a/cll1.h b/cll1.h index a5c4c9d..81f4887 100644 --- a/cll1.h +++ b/cll1.h @@ -101,7 +101,7 @@ /* ------------------------------------------------------------------- */ /* 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) /* ------------------------------------------------------------------- */ diff --git a/demos/hello.c b/demos/hello.c index 1713533..1212211 100644 --- a/demos/hello.c +++ b/demos/hello.c @@ -2,6 +2,6 @@ program { - echo("Hello ","world",NULL,"! "); - print("Hello ",NULL,"world","!"); + echo("Hello ",NULL,"world"," ! "); + print("Hello","world",NULL,"!"); } diff --git a/demos/performance/cll1-print.c b/demos/performance/cll1-print.c index eb20e07..611f166 100644 --- a/demos/performance/cll1-print.c +++ b/demos/performance/cll1-print.c @@ -1,12 +1,7 @@ #include "cll1.h" -#define RUNS 10000000UL program { - unsigned long i; - for_range(i,0,RUNS) - { + repeat(10000000) print("stuff"); - } - return 0; } diff --git a/demos/performance/cll1-print2.c b/demos/performance/cll1-print2.c new file mode 100644 index 0000000..662d41c --- /dev/null +++ b/demos/performance/cll1-print2.c @@ -0,0 +1,7 @@ +#include "cll1.h" + +program +{ + repeat(10000000) + print("stuff1","stuff2"); +} diff --git a/demos/performance/fputs2.c b/demos/performance/fputs2.c new file mode 100644 index 0000000..e2ef7e1 --- /dev/null +++ b/demos/performance/fputs2.c @@ -0,0 +1,14 @@ +#include + +#define RUNS 10000000UL +int main (void) +{ + unsigned long i; + for (i=0;i + +#define RUNS 10000000UL +int main (void) +{ + unsigned long i; + for (i=0;i /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 diff --git a/demos/performance/test-performance2 b/demos/performance/test-performance2 new file mode 100755 index 0000000..19d2bc5 --- /dev/null +++ b/demos/performance/test-performance2 @@ -0,0 +1,28 @@ +#!/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 diff --git a/demos/performance/test-results b/demos/performance/test-results new file mode 100644 index 0000000..2aa861c --- /dev/null +++ b/demos/performance/test-results @@ -0,0 +1,85 @@ +#!/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 + +#define RUNS 10000000UL +int main (void) +{ +unsigned long i; +for (i=0;i + +#define RUNS 10000000UL +int main (void) +{ +unsigned long i; +for (i=0;i + +#define RUNS 10000000UL +int main (void) +{ +unsigned long i; +for (i=0;i + +#define RUNS 10000000UL +int main (void) +{ + unsigned long i; + for (i=0;i + +#define RUNS 10000000UL +int main (void) +{ + unsigned long i; + for (i=0;i