Which is more efficient?

Регистрация
26.03.2012
Сообщения
44
Благодарностей
6
Баллы
0
I'm designing a template part that will be used pretty heavily within other templates that I plan to design so I want to make sure I'm doing it as well as I can.

If I have a text file with 10 or so lines in it and each line needs to be read but separated (not within one big block but 10 separate strings), I see two ways to do this.

1.) I could set up 10 steps each one with a macro to read one of the lines 0-9.

2.) I could set up 1 step to pull the whole block of text and then 10 steps to parse out the pieces needed.

I doubt it makes a whole lot of difference but thought if I had a ton of threads running trying to access this file over and over for the same info it might be slightly less efficient than if each thread only needed to access the file once. Then the info needed is all stored within that thread rather than having a ton of threads all accessing a specific file 10 times each.


Plus the file may end up being more than 10 lines long so the longer it gets the more important this would be - but I'm not 100% sure if this is true or not.

Am I thinking about this right? Which one is more efficient?
 

reislet

Client
Регистрация
02.04.2012
Сообщения
33
Благодарностей
1
Баллы
0
3) Use a loop. Your code will be shorter.

-Get number of strings from file
-Init a counter
-get counter value
-If counter < number of stings
-fetch string @counter (you can delete it or not i guess not)
-increase counter
- loop it back to the get counter value

The benefits: it can be dynamic without you interfering, let's say you have 11 lines all of a sudden and not 10.

3) is the adaptation of your first version, but you can loop 2.) as well with out creating 10 steps.
 
Регистрация
26.03.2012
Сообщения
44
Благодарностей
6
Баллы
0
Thanks for the reply :-) I considered something like that but the only problem in this particular instance is that each string within the file serves a specific purpose which is not necessarily directly related to the other strings. And the use of each string needs to be programmed into the template anyway or there would be no use having a step to fetch it.

There's no way you could have known that from the information I gave though, so that's my fault for not quite being clear enough on what I'm trying to accomplish.

Basically, I'm working to create a set of templates that can accomplish something similar to Senuke on steroids. This document that I'm reading from is like the brains for the templates. It is a set of controls, and each string needing to be fetched controls a certain aspect of the template (are we using proxies for this project? where is the list of usernames stored for this project? how will captchas be entered on the 1st and 2nd try? etc). All of the different options will be contained within this file, and some lines simply give explanation so they don't need to be fetched (the line after the captcha questions lists the different options available so that line does not need to be read by the template). Another reason I feel having individual steps is easier is because then when I need to use the information pulled in another branch I can just grab the results of that particular step.


Either way, I doubt it will make a huge difference, but I'm trying to plan this out so it will work for really big projects which might cause things like this to matter a little more...
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)