littleclown Posted November 20, 2010 Posted November 20, 2010 (edited) Hello. I need to search from the beginning in the huge ($ar[1000000]) array for string bigger than X, then write down the position and continue search for number bigger than X. In final I should have list with all positions on numbers bigger than X. I need to use an array functions for this because if i create a loop for all one million numbers I will have a huge delay (as far I can see array-oriented commands are really faster than everything else) Thank you in advance. If there is something like _ArrayFindAll but with > < options will be great. Edited November 20, 2010 by littleclown
Moderators Melba23 Posted November 20, 2010 Moderators Posted November 20, 2010 littleclown, Quote if i create a loop for all one million numbers I will have a huge delay (as far I can see array-oriented commands are really faster than everything else)If you look inside Array.au3, you will see that _ArrayFindAll calls _ArraySearch which (horror !) uses a loop (For $i = $iStart To $iEnd)! In fact _Array* functions are usually pretty slow - particularly those which involve changing the size of the array. So I would just use a loop and accept that anything involving an array of that size is going to take a while to run. M23P.S. How on earth do you initialise the array? From where do you get the data? And what are you trying to do with it? Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Realm Posted November 20, 2010 Posted November 20, 2010 Hello littleclown, I never had speed issues with searching through an array with my own custom loops. But again, I never dealt with arrays this large. So I created a little test to see for myself. I buillt a loop to create the array assiging a random number between 0 and 99 to each index. Then initiated a timer for my search loop, then called the time difference after the the loop had finished and found that it found all indexes over 95 in less than 5 seconds. However the _ArrayDisplay() took almost a minute to load up. So if your experiencing large load times, it may have to do with your display method. Here is my example if you would like to time it yourself: expandcollapse popup#include <Array.au3> Local $x = 95 Local $ar[1000000] $timer1 = TimerInit() For $r = 0 To UBound($ar)-1 $ar[$r] = Random(0,99,1) Next $diff1 = _GetDiff($timer1) $timer2 = TimerInit() Local $indexes For $i = 0 To UBound($ar)-1 If $ar[$i] > $x Then $indexes &= $i & ',' Next $indexes = StringTrimRight($indexes,1) $diff2 = _GetDiff($timer2) $index_Array = StringSplit($indexes,',') _ArrayDisplay($index_Array,'Index Points') MsgBox(0,'Times','Time to populate Array: ' & $diff1 & @CRLF & 'Time to Search Array; ' & $diff2) _ArrayDisplay($ar,'Array view') Func _GetDiff($timer) Local $timeDiff = TimerDiff($timer), $hr, $min, $sec, $ms If $timeDiff < 1000 Then Return (Round($timeDiff) & ' milliseconds' ) ElseIf $timeDiff < 60000 Then $sec = Floor($timeDiff/1000) $ms = Round($timeDiff - ($sec * 1000)) Return ($sec & '.' & $ms & ' seconds') ElseIf $timeDiff < 3600000 Then $min = Floor($timeDiff/60000) $sec = Floor(($timeDiff - ($min * 60000))/1000) $ms = Round($timeDiff - ($sec * 1000) - ($min * 60000)) Return ($min & ':' & $sec & '.' & $ms & ' minutes') ElseIf $timeDiff>= 3600000 Then $hr = Floor($timeDiff/3600000) $min = Floor(($timeDiff-($hr * 3600000))/60000) $sec = Floor(($timeDiff - ($min * 60000)-($hr * 3600000))/1000) $ms = Round($timeDiff - ($sec * 1000) - ($min * 60000)-($hr * 3600000)) Return ($hr & ':' & $min & ':' & $sec & '.' & $ms & ' hours') EndIf Return SetError(1,0,0) EndFunc Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.
littleclown Posted November 20, 2010 Author Posted November 20, 2010 (edited) Let me check something. I use consolewrite - maybe the issue is there. Actually I try to analize wav file but on really low level (I know about bass, but i prefer to write it to my own). This is only 10 second wav file in a array . EDIT: 20 seconds! Thanks guys - maybe I just need somebody to think with me sometimes . I did not initialization issues, but can I be sure there will be no issues everywhere? I will distribute exe if it works. Edited November 20, 2010 by littleclown
SadBunny Posted November 20, 2010 Posted November 20, 2010 On 11/20/2010 at 4:26 PM, 'littleclown said: Let me check something. I use consolewrite - maybe the issue is there.Actually I try to analize wav file but on really low level (I know about bass, but i prefer to write it to my own). This is only 10 second wav file in a array .EDIT: 20 seconds! Thanks guys - maybe I just need somebody to think with me sometimes .I did not initialization issues, but can I be sure there will be no issues everywhere? I will distribute exe if it works.The only way to be sure there are no issues is to include Opt("BugFreeMode",1) in your code. And whether the exe is useful depends entirely on what it does Roses are FF0000, violets are 0000FF... All my base are belong to you.
littleclown Posted November 20, 2010 Author Posted November 20, 2010 I just need to run it under 32 and 64 bit XP, Vista and windows 7.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now