Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


How to compare Multi dimensional arrays

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,59911
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How to compare Multi dimensional arrays
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 How to compare Multi dimensional arrays - 5/7/2008 2:36:38 AM   
  lordsords

 

Posts: 3
Score: 0
Joined: 5/7/2008
Status: offline
 Hi everyone,

I am writing a script that would compare 2 tables inside an MSI file.
So I am trying to do it by reading each table into a multidimensional array and then comparing them.

The problem is that comparing takes a lot of time if the arrays are bigger.
e.g.
~55sec if arrays are 4000 entries each
~1min 20sec if arrays are 5000
~5min if arrays are 10 000 
20 000 - forever
The comparison is done like this:


      

Could someone give me a hint how it can be optimized?
 
 
Post #: 1
 
 RE: How to compare Multi dimensional arrays - 5/7/2008 2:43:50 AM   
  Rischip


Posts: 379
Score: 2
Joined: 3/26/2007
Status: offline
Can you post the rest of the code?

_____________________________

Rischip
Author of - The Grim Linker

(in reply to lordsords)
 
 
Post #: 2
 
 RE: How to compare Multi dimensional arrays - 5/7/2008 4:24:06 AM   
  lordsords

 

Posts: 3
Score: 0
Joined: 5/7/2008
Status: offline
The whole code would be:




      

(in reply to Rischip)
 
 
Post #: 3
 
 RE: How to compare Multi dimensional arrays - 5/7/2008 5:59:57 AM   
  ebgreen


Posts: 4595
Score: 29
Joined: 7/12/2005
Status: offline
My first question would be why use arrays in the first place? You are taking data that is in a data structure (a recordset) and you are putting it into a more primitive data structure (array). Why not just do the comparisons between the recordsets?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to lordsords)
 
 
Post #: 4
 
 RE: How to compare Multi dimensional arrays - 5/7/2008 7:28:11 AM   
  lordsords

 

Posts: 3
Score: 0
Joined: 5/7/2008
Status: offline
I am not a programmer - I created this by combining several scripts
Could you provide a code sample of what you mean?

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: How to compare Multi dimensional arrays - 5/7/2008 7:53:53 AM   
  ebgreen


Posts: 4595
Score: 29
Joined: 7/12/2005
Status: offline
Ok, so you query a database. The query returns a recordset. That is essentially what you are looping through to add everything to an array. Instead of adding to and array, make two recordsets (oRecx and oRecy) then loop through them just like you already are. Instead of adding the contents of each record to an array, just compare each record in oRecx to the same record in oRecy.


_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to lordsords)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How to compare Multi dimensional arrays Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts