From 72c9d7a0a7562f1d480c0c023bb15163a7b3f803 Mon Sep 17 00:00:00 2001 From: xchaos Date: Wed, 23 Jan 2008 09:47:27 +0000 Subject: [PATCH] Python range vs. xrange comparison added git-svn-id: https://dev.arachne.cz/repos/cll1h/trunk@33 4bb87942-c103-4e5a-b51c-0ebff58f8515 --- demos/performance/test-performance.sh | 4 ++ demos/performance/test-performance2.sh | 4 ++ demos/performance/test-results | 54 +++++++++++++++----------- demos/performance/test-results2 | 44 ++++++++++++--------- demos/performance/xrange.py | 5 +++ demos/performance/xrange2.py | 5 +++ 6 files changed, 75 insertions(+), 41 deletions(-) create mode 100755 demos/performance/xrange.py create mode 100755 demos/performance/xrange2.py diff --git a/demos/performance/test-performance.sh b/demos/performance/test-performance.sh index 7c9af2f..a31b74a 100755 --- a/demos/performance/test-performance.sh +++ b/demos/performance/test-performance.sh @@ -8,6 +8,10 @@ cat print.py echo "Running..." time ./print.py > /dev/null +cat xrange.py +echo "Running..." +time ./xrange.py > /dev/null + cat echo.php echo "Running..." time ./echo.php > /dev/null diff --git a/demos/performance/test-performance2.sh b/demos/performance/test-performance2.sh index 46e4a1d..1df237a 100755 --- a/demos/performance/test-performance2.sh +++ b/demos/performance/test-performance2.sh @@ -8,6 +8,10 @@ cat print2.py echo "Running..." time ./print2.py > /dev/null +cat xrange2.py +echo "Running..." +time ./xrange2.py > /dev/null + cat echo2.php echo "Running..." time ./echo2.php > /dev/null diff --git a/demos/performance/test-results b/demos/performance/test-results index 72f50a6..de52fd9 100644 --- a/demos/performance/test-results +++ b/demos/performance/test-results @@ -2,16 +2,24 @@ 10000000.times { print "stuff","\n" } Running... -14.58user 1.54system 0:16.27elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+457minor)pagefaults 0swaps +14.40user 1.62system 0:16.46elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+456minor)pagefaults 0swaps #!/usr/bin/python for i in range(1,10000000): print "stuff" Running... -8.28user 0.15system 0:08.61elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k +8.24user 0.16system 0:08.40elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+39997minor)pagefaults 0swaps +#!/usr/bin/python + +for i in xrange(1,10000000): + print "stuff" + +Running... +7.94user 0.00system 0:08.09elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+701minor)pagefaults 0swaps #!/usr/bin/php5 -q Running... -4.93user 2.01system 0:07.24elapsed 95%CPU (0avgtext+0avgdata 0maxresident)k +4.80user 2.08system 0:07.08elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+1282minor)pagefaults 0swaps #!/usr/bin/perl @@ -31,8 +39,8 @@ for ($i=0;$i<10000000;$i++) } Running... -2.56user 0.00system 0:02.73elapsed 93%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+425minor)pagefaults 0swaps +2.46user 0.00system 0:02.47elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+424minor)pagefaults 0swaps #include #define RUNS 10000000UL @@ -45,10 +53,10 @@ int main() return 0; } Compiling... -0.34user 0.03system 0:00.38elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+8690minor)pagefaults 0swaps +0.31user 0.04system 0:00.37elapsed 95%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+8691minor)pagefaults 0swaps Running... -1.01user 0.00system 0:01.03elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k +1.02user 0.00system 0:01.03elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+238minor)pagefaults 0swaps #include "cll1.h" @@ -58,10 +66,10 @@ program print("stuff"); } Compiling... -0.09user 0.00system 0:00.09elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+3999minor)pagefaults 0swaps +0.07user 0.01system 0:00.09elapsed 90%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+4001minor)pagefaults 0swaps Running... -0.84user 0.01system 0:00.93elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k +0.88user 0.00system 0:00.90elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+131minor)pagefaults 0swaps #include @@ -75,11 +83,11 @@ printf("stuff\n"); return 0; } Compiling... -0.06user 0.00system 0:00.06elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+3780minor)pagefaults 0swaps +0.05user 0.00system 0:00.06elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+3781minor)pagefaults 0swaps Running... -0.61user 0.00system 0:00.62elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+115minor)pagefaults 0swaps +0.61user 0.00system 0:00.61elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+114minor)pagefaults 0swaps #include #define RUNS 10000000UL @@ -92,11 +100,11 @@ puts("stuff"); return 0; } Compiling... -0.03user 0.02system 0:00.06elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+3778minor)pagefaults 0swaps +0.05user 0.00system 0:00.05elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+3777minor)pagefaults 0swaps Running... -0.62user 0.00system 0:00.63elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+114minor)pagefaults 0swaps +0.62user 0.00system 0:00.65elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+115minor)pagefaults 0swaps #include #define RUNS 10000000UL @@ -109,8 +117,8 @@ fputs("stuff\n",stdout); return 0; } Compiling... -0.04user 0.01system 0:00.06elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+3787minor)pagefaults 0swaps +0.04user 0.01system 0:00.05elapsed 94%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+3785minor)pagefaults 0swaps Running... -0.56user 0.00system 0:00.56elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k +0.57user 0.00system 0:00.57elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+115minor)pagefaults 0swaps diff --git a/demos/performance/test-results2 b/demos/performance/test-results2 index 60ef067..f047a22 100644 --- a/demos/performance/test-results2 +++ b/demos/performance/test-results2 @@ -2,7 +2,7 @@ 10000000.times { print "stuff1"," ","stuff2","\n" } Running... -23.14user 1.62system 0:25.61elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k +23.56user 1.60system 0:25.50elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+457minor)pagefaults 0swaps #!/usr/bin/python @@ -10,8 +10,16 @@ for i in range(1,10000000): print "stuff1","stuff2" Running... -13.50user 0.18system 0:13.83elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+39996minor)pagefaults 0swaps +13.38user 0.20system 0:13.60elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+39997minor)pagefaults 0swaps +#!/usr/bin/python + +for i in xrange(1,10000000): + print "stuff1","stuff2" + +Running... +12.78user 0.00system 0:12.81elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+700minor)pagefaults 0swaps #!/usr/bin/php5 -q Running... -9.87user 2.20system 0:12.37elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k +9.90user 2.00system 0:11.93elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+1282minor)pagefaults 0swaps #include @@ -34,10 +42,10 @@ int main() return 0; } Compiling... -0.35user 0.04system 0:00.40elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+8699minor)pagefaults 0swaps +0.32user 0.04system 0:00.37elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+8700minor)pagefaults 0swaps Running... -6.22user 1.82system 0:08.07elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k +6.15user 1.99system 0:08.15elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+241minor)pagefaults 0swaps #!/usr/bin/perl @@ -47,7 +55,7 @@ for ($i=0;$i<10000000;$i++) print ("stuff1"," ","stuff2","\n"); } Running... -5.74user 0.01system 0:05.93elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k +5.56user 0.02system 0:05.60elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+425minor)pagefaults 0swaps #include "cll1.h" @@ -57,10 +65,10 @@ program print("stuff1","stuff2"); } Compiling... -0.08user 0.01system 0:00.09elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+4000minor)pagefaults 0swaps +0.08user 0.00system 0:00.09elapsed 94%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+3999minor)pagefaults 0swaps Running... -1.92user 0.01system 0:01.94elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k +1.90user 0.02system 0:01.94elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+131minor)pagefaults 0swaps #include @@ -74,11 +82,11 @@ int main (void) return 0; } Compiling... -0.04user 0.02system 0:00.06elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k +0.03user 0.02system 0:00.06elapsed 90%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3781minor)pagefaults 0swaps Running... -2.89user 0.01system 0:02.92elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+121minor)pagefaults 0swaps +2.85user 0.01system 0:02.87elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+122minor)pagefaults 0swaps #include #define RUNS 10000000UL @@ -94,8 +102,8 @@ int main (void) return 0; } Compiling... -0.04user 0.02system 0:00.06elapsed 104%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+3788minor)pagefaults 0swaps +0.05user 0.00system 0:00.05elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+3787minor)pagefaults 0swaps Running... -1.50user 0.00system 0:01.51elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (0major+115minor)pagefaults 0swaps +1.53user 0.00system 0:01.53elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k +0inputs+0outputs (0major+116minor)pagefaults 0swaps diff --git a/demos/performance/xrange.py b/demos/performance/xrange.py new file mode 100755 index 0000000..8f6ca3b --- /dev/null +++ b/demos/performance/xrange.py @@ -0,0 +1,5 @@ +#!/usr/bin/python + +for i in xrange(1,10000000): + print "stuff" + diff --git a/demos/performance/xrange2.py b/demos/performance/xrange2.py new file mode 100755 index 0000000..3b90701 --- /dev/null +++ b/demos/performance/xrange2.py @@ -0,0 +1,5 @@ +#!/usr/bin/python + +for i in xrange(1,10000000): + print "stuff1","stuff2" + -- 2.30.2