Loading...


bookmark - Speed And The Incrementation Methods essay

Speed And The Incrementation Methods - essay

 
 Discussion by WaCo with 2 Replies.
 Last Update: August 27, 2005, 1:31 pm
 
bookmark - Speed And The Incrementation Methods essay  
Quickly Post to Speed And The Incrementation Methods essay w/o signup Share Info about Speed And The Incrementation Methods essay using Facebook, Twitter etc. email your friend about Speed And The Incrementation Methods essay Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

"Speed of various incremetation methods"

1) Method one

CODE

[tomek@localhost ebooks]$ LEGAL=1 LEGAL_2=1; LEGAL_3=1;
for i in `seq 100000`; do LEGAL=$(( $LEGAL + 1 ));
LEGAL_2=$(( $LEGAL_2 + 1 ));
LEGAL_3=$(( $LEGAL_3 + 1 ));  done;
echo legal\'s value is "$LEGAL"

Avarage amount of time that the process took: 9 seconds 29 hundredth.



2) Method two

CODE

[tomek@localhost ebooks]$ LEGAL=1 LEGAL_2=1;LEGAL_3=1;
for i in `seq 100000`; do LEGAL=$[LEGAL + 1];
LEGAL_2=$[LEGAL_2 + 1];
LEGAL_3=$[LEGAL_3 + 1];  done;
echo legal\'s value is "$LEGAL"

Avarage amount of time that the process took: 6 seconds 99 hundredth.



3) Method three

CODE

[tomek@localhost ebooks]$ LEGAL=1 LEGAL_2=1; LEGAL_3=1;
for i in `seq 100000`; do LEGAL=`echo $LEGAL + 1 | bc`;
LEGAL_2=`echo $LEGAL_2 + 1 | bc`;
LEGAL_3=`echo $LEGAL_3 + 1 | bc`;  done;
echo legal\'s value is "$LEGAL"

Avarage amount of time that the process took: 5 000 seconds.



4) Metoda four

CODE

[tomek@localhost ebooks]$ LEGAL=1 LEGAL_2=1; LEGAL_3=1;
for i in `seq 100000`; do LEGAL=`expr $LEGAL + 1`;
LEGAL_2=`expr $LEGAL_2 + 1`;
LEGAL_3=`expr $LEGAL_3 + 1`;  done;
echo legal\'s value is "$LEGAL"

Avarage amount of time that the process took: 2 000 seconds.



5) C++ example for comprehension

CODE

#include <iostream>
using namespace std;
int main()
{
 float a;
 for ( a=1; a <= 10000000; a++ ) { /*  100 x more than in bash !!!  */
 }
 cout << a;
return 0;
}

Avarage amount of time that the process took: not even a second.

Conclusion: The best incrementation method is second method, but compared to hightech programming languages it's still very slow.

Notes: tests were held on Duron 733 Mhz, 128 mb ram, riva tnt 2 32 mb.




[Added 2005-08-11, 07:49:21]

   Wed Aug 10, 2005    Reply         

I understand what it is, it is a rundown on various methods of incrementing values and how long they take. It seems to be doing so in batch scripting, perhaps we should ove it there?

~Viz

   Fri Aug 12, 2005    Reply         

The comparason to c++ is not fair.
You will probably find that the c++ compiler is optimising your code, and replacing

CODE

 for ( a=1; a <= 10000000; a++ ) { /*  100 x more than in bash !!!  */
}


with the following code

CODE

a=10000000;


both pieces of code achieve the same end result.

try compiling the the zero optimise flag -O0

   Sat Aug 27, 2005    Reply         


Quickly Post to Speed And The Incrementation Methods essay w/o signup Share Info about Speed And The Incrementation Methods essay using Facebook, Twitter etc. email your friend about Speed And The Incrementation Methods essay Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Similar Topics:

Boost Up Your Computer Speed

Has YOUR computer applications taken long to load up? Believe it or not, and for those of you who don't know, there IS a solution! ...more

   01-Apr-2006    Reply         

Internet Speed Test

Hai , I have introduced a Bandwidth Speed Test Service in my website located @ http://www.jbi.in I request you to post your speed test results here : First let me start : Service Provider Details : ...more

   15-Jul-2007    Reply         

Need For Speed Shift

Hey all anywone knowing when this game is going to out? i heard that its going to be like GRID The Grafichs ,Realism ,Sound ,Interface etc Appears to be a good game thats going to be ...more

   05-Jun-2009    Reply         

Adding Ttf Fonts To Your Linux so you can really get into gimping :)   Adding Ttf Fonts To Your Linux so you can really get into gimping :) (0) (6) Multislot Usb Memory Card Readers detecting newly inserted cards!  Multislot Usb Memory Card Readers detecting newly inserted cards!