View previous topic :: View next topic
|
Author |
Message |
mikayag
New User
Joined: 10 Mar 2005 Posts: 16
|
|
|
|
Hi,
I have this program:
MOVE 'VALUE1' TO SEARCH-TEXT
PERFORM SEARCH-VALUE
IF SW-TEXT-FOUND
MOVE TXT-DESC TO FLD-DESCRIPT
ELSE
MOVE SEARCH-TEXT TO FLD-DESCRIPT
END-IF
MOVE 'VALUE2' TO SEARCH-TEXT
PERFORM SEARCH-VALUE
IF SW-TEXT-FOUND
MOVE TXT-DESC TO FLD-DESCRIPT
ELSE
MOVE SEARCH-TEXT TO FLD-DESCRIPT
END-IF
I have around 10-12 successive codes like this. The SEARCH-VALUE paragraph uses binary search (SEARCH ALL).
How can I rewrite this code to improve performance? |
|
Back to top |
|
|
ramfrom84
New User
Joined: 23 Aug 2006 Posts: 93 Location: chennai
|
|
|
|
Can u explain ur requriment more details with the Input File,
For example the Input File and compare File both key is ascending order, Then we can aovid both search option it ll help to reduce more time since u r using two times search option for single record.
Thanks... |
|
Back to top |
|
|
TG Murphy
Active User
Joined: 23 Mar 2007 Posts: 148 Location: Ottawa Canada
|
|
|
|
Binary search is very fast. As Ramfrom says, hard to suggest optimizations without knowing more info.
Why have you concluded that your logic is too slow? I would suggest that you review this conclusion. Are you sure these searches are your problem? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You mention value1, value2 and so forth for 10-12 values. Might any of these values be the same as a previous value in the same set of values?
If the answer is yes, you might group your values and not re-do the search for duplicates - whatever was found or not found will persist for the particular iteration.
As was posted previously, if you more completely describe your process we may be able to offer better suggestions. Also, please clarify what measurement determined this runs too slow. |
|
Back to top |
|
|
niteshsurana
New User
Joined: 27 Oct 2006 Posts: 4 Location: india
|
|
|
|
In case you have a number of values you can always try the option for a Table use and then search accordingly. This would reduce the overhead for the rest 11 searches. |
|
Back to top |
|
|
|