From 2814fb597e395b54b421123dd51fff55866f1faf Mon Sep 17 00:00:00 2001 From: xchaos Date: Thu, 31 Jan 2008 00:07:00 +0000 Subject: [PATCH] Tiny C test added git-svn-id: https://dev.arachne.cz/repos/cll1h/trunk@50 4bb87942-c103-4e5a-b51c-0ebff58f8515 --- demos/performance/test-performance.sh | 115 ++++++----- demos/performance/test-performance2.sh | 109 +++++----- demos/performance/test-results | 263 ++++++++++++++++--------- demos/performance/test-results2 | 215 ++++++++++++-------- 4 files changed, 421 insertions(+), 281 deletions(-) diff --git a/demos/performance/test-performance.sh b/demos/performance/test-performance.sh index 5da7b51..e2de3e5 100755 --- a/demos/performance/test-performance.sh +++ b/demos/performance/test-performance.sh @@ -1,25 +1,28 @@ #!/bin/bash echo `grep "model name" /proc/cpuinfo |cut -f 2 -d :` `grep "cpu MHz" /proc/cpuinfo |cut -f 2 -d :` Mhz ` grep "bogomips" /proc/cpuinfo |cut -f 2 -d :` bogomips -echo "------------------------------------------------------------- Ruby" -cat print.rb -echo -n "Running..." -time ./print.rb > /dev/null +if [ "$1" == "all" ] +then + echo "------------------------------------------------------------- Ruby" + cat print.rb + echo -n "Running..." + time ./print.rb > /dev/null -echo "--------------------------------------------------- Python - range" -cat print.py -echo -n "Running..." -time ./print.py > /dev/null + echo "--------------------------------------------------- Python - range" + cat print.py + echo -n "Running..." + time ./print.py > /dev/null -echo "-------------------------------------------------- Python - xrange" -cat xrange.py -echo -n "Running..." -time ./xrange.py > /dev/null + echo "-------------------------------------------------- Python - xrange" + cat xrange.py + echo -n "Running..." + time ./xrange.py > /dev/null -echo "------------------------------------------------------------ PHP 5" -cat echo.php -echo -n "Running..." -time ./echo.php > /dev/null + echo "------------------------------------------------------------ PHP 5" + cat echo.php + echo -n "Running..." + time ./echo.php > /dev/null +fi echo "-------------------------------------------------- C - gcc - write" cat write.c @@ -47,43 +50,49 @@ time g++ -O2 cout.cpp -o cout echo -n "Running..." time ./cout > /dev/null -#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" +echo "----------------------------------------------- C<<1 - tcc - print" +cat cll1-print.c +echo -n "Compiling..." +time tcc 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 printf.c -o printf +echo -n "Running..." +time ./printf > /dev/null + +echo "------------------------------------------------ C<<1 - tcc - echo" +cat cll1-echo.c +echo -n "Compiling..." +time tcc cll1-echo.c -o cll1-echo +echo -n "Running..." +time ./puts > /dev/null + +echo "--------------------------------------------------- C - tcc - puts" +cat puts.c +echo -n "Compiling..." +time tcc puts.c -o puts +echo -n "Running..." +time ./puts > /dev/null + +echo "------------------------------------------------- C - tcc - fwrite" +cat fwrite.c +echo -n "Compiling..." +time tcc fwrite.c -o fwrite +echo -n "Running..." +time ./fwrite > /dev/null + +echo "-------------------------------------------------- C - tcc - fputs" +cat fputs.c +echo -n "Compiling..." +time tcc fputs.c -o fputs +echo -n "Running..." +time ./fputs > /dev/null + +echo "------------------------------------------------ C<<1 - gcc - echo" cat cll1-echo.c echo -n "Compiling..." time gcc -O2 cll1-echo.c -o cll1-echo diff --git a/demos/performance/test-performance2.sh b/demos/performance/test-performance2.sh index b99b9b1..73b0a7f 100755 --- a/demos/performance/test-performance2.sh +++ b/demos/performance/test-performance2.sh @@ -1,29 +1,32 @@ #!/bin/bash echo `grep "model name" /proc/cpuinfo |cut -f 2 -d :` `grep "cpu MHz" /proc/cpuinfo |cut -f 2 -d :` Mhz ` grep "bogomips" /proc/cpuinfo |cut -f 2 -d :` bogomips -echo "------------------------------------------------------------- Ruby" -cat print2.rb -echo -n "Running..." -time ./print2.rb > /dev/null -echo +if [ "$1" == "all" ] +then + echo "------------------------------------------------------------- Ruby" + cat print2.rb + echo -n "Running..." + time ./print2.rb > /dev/null + echo -echo "--------------------------------------------------- Python - range" -cat print2.py -echo -n "Running..." -time ./print2.py > /dev/null -echo + echo "--------------------------------------------------- Python - range" + cat print2.py + echo -n "Running..." + time ./print2.py > /dev/null + echo -echo "-------------------------------------------------- Python - xrange" -cat xrange2.py -echo -n "Running..." -time ./xrange2.py > /dev/null -echo + echo "-------------------------------------------------- Python - xrange" + cat xrange2.py + echo -n "Running..." + time ./xrange2.py > /dev/null + echo -echo "------------------------------------------------------------ PHP 5" -cat echo2.php -echo -n "Running..." -time -f "%E total, %U user, %S sys" ./echo2.php > /dev/null -echo + echo "------------------------------------------------------------ PHP 5" + cat echo2.php + echo -n "Running..." + time ./echo2.php > /dev/null + echo +fi echo "-------------------------------------------------- C - gcc - write" cat write2.c @@ -44,41 +47,41 @@ echo echo "------------------------------------------------------------- Perl" cat print2.pl echo -n "Running..." -time -f "%E total, %U user, %S sys" ./print2.pl > /dev/null +time ./print2.pl > /dev/null +echo + +echo "------------------------------------------------- C - tcc - printf" +cat printf2.c +echo -n "Compiling..." +time tcc printf2.c -o printf2 +echo -n "Running..." +time ./printf2 > /dev/null +echo + +echo "------------------------------------------------- C - tcc - fwrite" +cat fwrite2.c +echo -n "Compiling..." +time tcc 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 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 fputs2.c -o fputs2 +echo -n "Running..." +time ./fputs2 > /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..." diff --git a/demos/performance/test-results b/demos/performance/test-results index af9d68b..ce89556 100644 --- a/demos/performance/test-results +++ b/demos/performance/test-results @@ -1,44 +1,4 @@ -------------------------------------------------------------- Ruby -#!/usr/bin/ruby - -10000000.times { print "stuff","\n" } - -Running... -real 0m16.104s -user 0m14.353s -sys 0m1.412s ---------------------------------------------------- Python - range -#!/usr/bin/python - -for i in range(1,10000000): - print "stuff" - -Running... -real 0m8.661s -user 0m8.465s -sys 0m0.168s --------------------------------------------------- Python - xrange -#!/usr/bin/python - -for i in xrange(1,10000000): - print "stuff" - -Running... -real 0m8.480s -user 0m8.433s -sys 0m0.016s ------------------------------------------------------------- PHP 5 -#!/usr/bin/php5 -q - -Running... -real 0m7.098s -user 0m5.048s -sys 0m2.024s +AMD Athlon(tm) XP 1259.487 Mhz 2522.30 bogomips -------------------------------------------------- C - gcc - write #include @@ -56,13 +16,13 @@ int main (void) return 0; } Compiling... -real 0m0.061s -user 0m0.048s -sys 0m0.012s +real 0m1.102s +user 0m0.212s +sys 0m0.044s Running... -real 0m2.906s -user 0m0.848s -sys 0m2.028s +real 0m7.171s +user 0m1.636s +sys 0m5.536s ------------------------------------------------------------- Perl #!/usr/bin/perl @@ -73,9 +33,9 @@ for ($i=0;$i<10000000;$i++) } Running... -real 0m2.515s -user 0m2.484s -sys 0m0.008s +real 0m5.808s +user 0m5.600s +sys 0m0.012s ----------------------------------------------- C<<1 - gcc - print #include "cll1.h" @@ -85,13 +45,13 @@ program print("stuff"); } Compiling... -real 0m0.121s -user 0m0.112s -sys 0m0.008s +real 0m0.567s +user 0m0.352s +sys 0m0.028s Running... -real 0m1.249s -user 0m1.240s -sys 0m0.004s +real 0m2.122s +user 0m2.112s +sys 0m0.008s ---------------------------------------------- C - g++ - std::cout #include @@ -106,14 +66,51 @@ int main() return 0; } Compiling... -real 0m0.362s -user 0m0.320s -sys 0m0.036s +real 0m1.973s +user 0m1.016s +sys 0m0.100s Running... -real 0m0.990s -user 0m0.984s -sys 0m0.004s ------------------------------------------------= C<<1 - gcc - echo +real 0m1.763s +user 0m1.752s +sys 0m0.012s +----------------------------------------------- C<<1 - tcc - print +#include "cll1.h" + +program +{ + repeat(10000000) + print("stuff"); +} +Compiling... +real 0m0.148s +user 0m0.020s +sys 0m0.008s +Running... +real 0m2.259s +user 0m2.252s +sys 0m0.008s +------------------------------------------------- C - tcc - printf +#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 +#include + +#define RUNS 10000000UL +int main (void) +{ + unsigned long i; + char *s1="stuff\n"; + int l1=strlen(s1); + + for (i=0;i + +#define RUNS 10000000UL +int main (void) +{ + unsigned long i; + for (i=0;i @@ -144,13 +225,13 @@ int main (void) return 0; } Compiling... -real 0m0.067s -user 0m0.040s -sys 0m0.024s +real 0m0.196s +user 0m0.164s +sys 0m0.032s Running... -real 0m0.630s -user 0m0.608s -sys 0m0.012s +real 0m1.106s +user 0m1.104s +sys 0m0.004s --------------------------------------------------- C - gcc - puts #include @@ -165,13 +246,13 @@ int main (void) return 0; } Compiling... -real 0m0.058s -user 0m0.036s -sys 0m0.024s +real 0m0.197s +user 0m0.172s +sys 0m0.028s Running... -real 0m0.633s -user 0m0.632s -sys 0m0.000s +real 0m1.105s +user 0m1.084s +sys 0m0.020s ------------------------------------------------- C - gcc - fwrite #include #include @@ -190,13 +271,13 @@ int main (void) return 0; } Compiling... -real 0m0.137s -user 0m0.060s -sys 0m0.008s +real 0m0.216s +user 0m0.188s +sys 0m0.028s Running... -real 0m0.555s -user 0m0.548s -sys 0m0.004s +real 0m1.027s +user 0m1.012s +sys 0m0.012s -------------------------------------------------- C - gcc - fputs #include @@ -211,10 +292,10 @@ int main (void) return 0; } Compiling... -real 0m0.058s -user 0m0.040s -sys 0m0.016s +real 0m0.199s +user 0m0.152s +sys 0m0.048s Running... -real 0m0.551s -user 0m0.548s -sys 0m0.004s +real 0m1.023s +user 0m1.008s +sys 0m0.016s diff --git a/demos/performance/test-results2 b/demos/performance/test-results2 index b451d20..be620a2 100644 --- a/demos/performance/test-results2 +++ b/demos/performance/test-results2 @@ -1,49 +1,4 @@ -------------------------------------------------------------- Ruby -#!/usr/bin/ruby - -10000000.times { print "stuff1"," ","stuff2","\n" } - -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... -real 0m13.571s -user 0m13.369s -sys 0m0.200s - --------------------------------------------------- Python - xrange -#!/usr/bin/python - -for i in xrange(1,10000000): - print "stuff1","stuff2" - -Running... -real 0m13.118s -user 0m13.105s -sys 0m0.012s - ------------------------------------------------------------- PHP 5 -#!/usr/bin/php5 -q - -Running..../test-performance2.sh: line 24: -f: command not found - -real 0m0.001s -user 0m0.000s -sys 0m0.000s - +AMD Athlon(tm) XP 1259.487 Mhz 2522.30 bogomips -------------------------------------------------- C - gcc - write #include @@ -66,13 +21,13 @@ int main (void) return 0; } Compiling... -real 0m0.063s -user 0m0.044s -sys 0m0.016s +real 0m0.205s +user 0m0.172s +sys 0m0.032s Running... -real 0m11.514s -user 0m3.572s -sys 0m7.928s +real 0m28.001s +user 0m6.400s +sys 0m21.597s ---------------------------------------------- C - g++ - std::cout #include @@ -87,13 +42,13 @@ int main() return 0; } Compiling... -real 0m0.367s -user 0m0.336s -sys 0m0.024s +real 0m1.087s +user 0m0.988s +sys 0m0.100s Running... -real 0m8.012s -user 0m6.092s -sys 0m1.812s +real 0m15.557s +user 0m10.461s +sys 0m5.096s ------------------------------------------------------------- Perl #!/usr/bin/perl @@ -103,11 +58,104 @@ for ($i=0;$i<10000000;$i++) { print ("stuff1"," ","stuff2","\n"); } -Running..../test-performance2.sh: line 46: -f: command not found +Running... +real 0m10.660s +user 0m10.361s +sys 0m0.028s + +------------------------------------------------- C - tcc - printf +#include -real 0m0.001s +#define RUNS 10000000UL +int main (void) +{ + unsigned long i; + for (i=0;i +#include + +#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 + +#define RUNS 10000000UL +int main (void) +{ + unsigned long i; + for (i=0;i @@ -123,13 +171,13 @@ int main (void) return 0; } Compiling... -real 0m0.098s -user 0m0.080s -sys 0m0.016s +real 0m0.199s +user 0m0.164s +sys 0m0.036s Running... -real 0m2.818s -user 0m2.820s -sys 0m0.000s +real 0m5.027s +user 0m4.996s +sys 0m0.032s ------------------------------------------------- C - gcc - fwrite #include @@ -154,13 +202,13 @@ int main (void) return 0; } Compiling... -real 0m0.070s -user 0m0.052s +real 0m0.221s +user 0m0.204s sys 0m0.016s Running... -real 0m2.665s -user 0m2.624s -sys 0m0.012s +real 0m3.770s +user 0m3.664s +sys 0m0.028s ----------------------------------------------- C<<1 - gcc - print #include "cll1.h" @@ -171,13 +219,13 @@ program print("stuff1","stuff2"); } Compiling... -real 0m0.121s -user 0m0.100s -sys 0m0.016s +real 0m0.364s +user 0m0.352s +sys 0m0.012s Running... -real 0m2.510s -user 0m2.508s -sys 0m0.004s +real 0m4.519s +user 0m4.504s +sys 0m0.016s -------------------------------------------------- C - gcc - fputs #include @@ -195,11 +243,10 @@ int main (void) return 0; } Compiling... -real 0m0.060s -user 0m0.052s -sys 0m0.008s +real 0m0.205s +user 0m0.180s +sys 0m0.024s Running... -real 0m1.567s -user 0m1.560s -sys 0m0.008s - +real 0m2.642s +user 0m2.612s +sys 0m0.032s -- 2.30.2