Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Speed And The Incrementation Methods, essay
WaCo
post Aug 11 2005, 05:36 AM
Post #1


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 9
Joined: 11-August 05
Member No.: 7,762



"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]
Go to the top of the page
 
+Quote Post
vizskywalker
post Aug 12 2005, 06:39 PM
Post #2


Techno-Necromancer
Group Icon

Group: Members
Posts: 1,018
Joined: 13-January 05
From: The Net
Member No.: 2,127



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
Go to the top of the page
 
+Quote Post
qwijibow
post Aug 27 2005, 08:31 PM
Post #3


Way Out Of Control - You need a life :)
Group Icon

Group: Members
Posts: 1,366
Joined: 14-September 04
From: Nottingham England
Member No.: 570



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
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Free Online Speed Test(13)
  2. Need For Speed Carbon(26)
  3. Is Your Internet Speed Good Enough Vs. Cost ?(88)
  4. Need For Speed Most Wanted!(19)
  5. Speed Up Your Connection In Windows XP(41)
  6. How To Turn Off Blur Effect In Nfsmw(1)
  7. How To Increase Windows Shutdown Speed(39)
  8. Flashget Download Manage(0)
  9. What Speed And Package U Getting From Your Isp?(52)
  10. Burn Dvd Over 16x Speed Rate(5)
  11. Increase Internet Speed For Win Xp Home(9)
  12. Bonding Network Interfaces For Double Speed?(0)
  13. Speed up your windows and Pc!(21)
  14. Internet Speed Test(13)
  15. How Do I Improve Wireless Speed?(14)
  1. Need For Speed Pro Street Ps3 And Xbox 360(0)
  2. Need For Speed Pro Street(2)
  3. Vb.net: How To Trap Exceptions In Invoked Methods?(5)
  4. How To Surf & Download Efficiently(7)
  5. C# Tutorial : Lesson 8 - Functions/methods(0)
  6. Speed Touch Usb Password Question(6)
  7. Joke - Funny Essay On Indian History(2)
  8. How To Learn A Programming Language(11)
  9. Time Warping Or Not?(22)
  10. Wi-fi Speeds.(12)
  11. How To Double Firefox Speed(5)
  12. Improve Xp Shutdown Speed(0)
  13. Slow Down To Speed Up(8)
  14. Web Server Uplink Speed Is Very Slow(2)
  15. NFSU2(39)


 



- Lo-Fi Version Time is now: 7th October 2008 - 06:47 PM