perforamnce test for printing one and two strings in C,C++,C<<1,Perl and Python
authorxchaos <xchaos@4bb87942-c103-4e5a-b51c-0ebff58f8515>
Tue, 22 Jan 2008 10:27:35 +0000 (10:27 +0000)
committerxchaos <xchaos@4bb87942-c103-4e5a-b51c-0ebff58f8515>
Tue, 22 Jan 2008 10:27:35 +0000 (10:27 +0000)
git-svn-id: https://dev.arachne.cz/repos/cll1h/trunk@22 4bb87942-c103-4e5a-b51c-0ebff58f8515

12 files changed:
cll1.h
demos/hello.c
demos/performance/cll1-print.c
demos/performance/cll1-print2.c [new file with mode: 0644]
demos/performance/fputs2.c [new file with mode: 0644]
demos/performance/print2.pl [new file with mode: 0755]
demos/performance/print2.py [new file with mode: 0755]
demos/performance/printf2.c [new file with mode: 0644]
demos/performance/test-performance
demos/performance/test-performance2 [new file with mode: 0755]
demos/performance/test-results [new file with mode: 0644]
demos/performance/test-results2 [new file with mode: 0644]

diff --git a/cll1.h b/cll1.h
index a5c4c9d60dd8c00e77fb4270ed8bea2a5fda9779..81f4887429725c08fb34b9397fdaaa47fa75f8f4 100644 (file)
--- a/cll1.h
+++ b/cll1.h
 /* ------------------------------------------------------------------- */
 /* 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)
 /* ------------------------------------------------------------------- */
index 17135333fca1d3108dfb2b8c3fb7908aef447f0b..1212211d5f2378680cb28b482e43668bc3fcffc0 100644 (file)
@@ -2,6 +2,6 @@
 
 program
 {
- echo("Hello ","world",NULL,"! ");
- print("Hello ",NULL,"world","!");
+ echo("Hello ",NULL,"world","  ! ");
+ print("Hello","world",NULL,"!");
 }
index eb20e077ad9bf0b4e1e96588d744dd3cc01c4d62..611f16664d2bef73839e108701920a9d86540e9d 100644 (file)
@@ -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 (file)
index 0000000..662d41c
--- /dev/null
@@ -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 (file)
index 0000000..e2ef7e1
--- /dev/null
@@ -0,0 +1,14 @@
+#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;
+}
diff --git a/demos/performance/print2.pl b/demos/performance/print2.pl
new file mode 100755 (executable)
index 0000000..c27a362
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/perl
+
+my $i=0;
+for ($i=0;$i<10000000;$i++)
+{
+ print ("stuff1"," ","stuff2","\n");
+}
diff --git a/demos/performance/print2.py b/demos/performance/print2.py
new file mode 100755 (executable)
index 0000000..36a44ce
--- /dev/null
@@ -0,0 +1,5 @@
+#!/usr/bin/python
+
+for i in range(1,10000000):
+ print "stuff1","stuff2"
+
diff --git a/demos/performance/printf2.c b/demos/performance/printf2.c
new file mode 100644 (file)
index 0000000..5ee4fb2
--- /dev/null
@@ -0,0 +1,11 @@
+#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;
+}
index 8a69facdeb3f0c0367206240c6c757bdcba5d511..df89664f726789ba4e0b8340d09de0a8adf7471f 100755 (executable)
@@ -1,24 +1,34 @@
 #!/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
diff --git a/demos/performance/test-performance2 b/demos/performance/test-performance2
new file mode 100755 (executable)
index 0000000..19d2bc5
--- /dev/null
@@ -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 (file)
index 0000000..2aa861c
--- /dev/null
@@ -0,0 +1,85 @@
+\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
diff --git a/demos/performance/test-results2 b/demos/performance/test-results2
new file mode 100644 (file)
index 0000000..7e98461
--- /dev/null
@@ -0,0 +1,69 @@
+\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
This page took 0.302189 seconds and 4 git commands to generate.