jeyes56 Posted February 9, 2013 Posted February 9, 2013 Hi, im making a program that converts the content of .CSV file to HTML view, the code is working fine but im having trouble in on the time of convertion, sometimes my convertion is fast and sometimes it takes time.. im thinking maybe my coding is wrong, that why im going to ask, did i code in the right way? expandcollapse popup..... ..... ..... ; this is my main loop $lines=around 50,000 for $x=$lines to 1 step -1 $y=$y+1 if $stop=1 then ExitLoop $pr=(100*(($lines-$x)/$lines))+1 progbar($pr,$pr,$t,$y) if $stop=1 then Return if ($arr[($x*7)-4]="") then $sender=$arr[($x*7)-5] Else $sender=$arr[($x*7)-4] EndIf if $arr[($x*7)-6]=" Received " then $co="blue" Else $co="red" EndIf for $z=1 to $pb[0][0] if StringInStr($pb[$z][0],$sender) then $t=$t+1 $sender="<b>"&$pb[$z][1]&"</b>" $f="<tr><td>"&$t&"</td><td>"&$sender&"</td><td><center><font color="&$co&">"&$arr[($x*7)-6]&"</font></td><td><center>"&$arr[($x*7)-2]&"</td><td>"&$arr[$x*7]&"</td></tr>"&@crlf&$f ExitLoop endif Next Next ..... .... ..... func progbar($x=0,$y=0,$n="",$nt="") $x=int($x) $y=int($y) if not($pp1prev=$x) then GUICtrlSetData($pp1,$x) GUICtrlSetData($p1,$x) GUICtrlSetData($num,$n) GUICtrlSetData($numt,$nt) $pp1prev=$x EndIf if not($pp2prev=$y) then GUICtrlSetData($pp2,$y) GUICtrlSetData($p2,$y) $pp2prev=$y EndIf $msg=GUIGetMsg() if $msg = $GUI_EVENT_CLOSE then MsgBox(0,"","User Canceled",5) $stop=1 progclose() EndIf EndFunc :: sometimes it is slow, sometimes it is fast, without any changes in another programs, activated or closed.
twitchyliquid64 Posted February 9, 2013 Posted February 9, 2013 Can you elaborate on what the $pb variable is?Im not sure if you are doing this, but if you only only update the progress in the GUI every now and then rather then every iteration or every 10 iterations you will also find it alot faster. I tend to use AdLibRegister functions to update GUIs.For the most part, your algorithm seems to have time complexity: O(n) where n is the number of elements in the CSV. With that in mind, program performance should be reliably linear, so massive fluctuations are pretty analogous.Are you feeding differently sized CSVs? are you sure your machine is not doing other stuff in the background? ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search
jeyes56 Posted February 13, 2013 Author Posted February 13, 2013 $pb may contain variables, in my testing i only used max of $pb[0][0]=5, it only contains list of names $pb[$x][1] with corresponding number $pb[$x][2]. what is iteration? i use this to update my progress bar, $pr=(100*(($lines-$x)/$lines))+1 progbar($pr,$pr,$t,$y) but the progressbar should only update when the $pr is an integer withour decimal point not equal to previous $pp2prev i have fix columns in CSV, its 7 columns (if im not mistaken) yes im sure im doing doing other stuffs in background, also, i tried to repeat and repeat the convertion, and sometimes its fast, sometimes its not, without any changes in other programs (opening or closing application)
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