Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Theory of a code speed increase...

Status
Not open for further replies.

PogoWolf

Programmer
Mar 2, 2001
351
US
Hello everyone,

I've got the following code:
Code:
Message = "Craft: Created..."
Pattern = "\[(?<Date>\S+)\s{1}(?<Time>\S+)\]\s{1}You have created (?<Amount>\d+)\s{1}(?<Item>.+)\."
Query = "INSERT INTO Craft (Date_Time, ToonID, ItemID, Amount, Created) Values (#[Date] [Time]#, [ToonID], [Item], [Amount], 1);"
DataDump (Message, Pattern, Query)

Repeat these lines changeing the information about 50 times..

the question is.. would it be faster to put the Message, Pattern, and Query into an Arraylist, and then iterate though the Array list, calling the DataDump funtion?



The PogoWolf
 
It would probably run slower because you have the overhead of iterating thru the ArrayList. What you've done by repeating the code (with changes) 50 times is called loop unrolling, and it's a common optimization.

Of course, it makes maintenance much harder, but if performance is your #1 goal, then maintenance can take a back seat.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
yeah, this project is already slow as hell.. LOL
but that's what I wanted to know.. I thought it would
be a little slower, but I wasn't sure if there would be
a 'make up' on the speed by having everything in the arraylist..

thanks, Chip.


The PogoWolf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top