Jump to content

Optimization tips


Recommended Posts

Hi everyone,

I've made a script that connects with a website and it reads data from there. The problem is that the total time for the script to complete is a few minutes (I don't think it's 5 minutes, but it's getting close to that) and I'd like to speed it up a bit.

I use the script to read my school schedule from the school web page and then convert that data into a .ics file (for use in digital agendas) and then upload that file to a host.

In pseudo code the script goes pretty much like this:

- Enter variables for class and from when to when to get the schedule

- Open up a hidden browser window with _IECreate

-- Loop through classes

--- Loop through weeks (from when to when to get the schedule)

--- Use _IENavigate to surf to the week schedule

--- Read with _IEDocReadHTML

--- Strip the read data of all useless data

--- Format and write to .ics file

-- Upload the file and delete local file after that

- Close IE window

- Exit

Most of the time the script is just waiting for webpages to load (more then 50% of the total time according to AU3Profiler). So I had the idea of opening all webpages in separate browser instances and then do a check to make sure they all loaded, but let's just say ~1200 instances of IE aren't really going to work :D

So I think I'm more or less out of options for optimization, with the exception of uploading all files in one go instead of each class individually.

But I'm hoping someone has an idea to do things differently and hopefully faster, so thanks in advance if you do!

This is the actual code (with my ftp login data removed), I know some includes are not necessary. I was planning on a GUI and stuff, but later on I decided not to do that as I'm only going to run it on my pc. I'll clean those up later :huggles:

#include <IE.au3>
#include <Date.au3>
#include <Array.au3>
#include <GUIConstants.au3>
#include <Misc.au3>

; all classes to get the schedule for
$class = "1GA-1a|1GA-1b|1GA-2a|1GA-2b|1GA-3a|1GA-3b|1GA-4a|1GA-4b|1GA-5a|1GA-5b|1GA-6|1GA-7|2GA-1a|2GA-1b|2GA-2a|2GA-2b|3GA-1a|3GA-1b|3GA-2a|3GA-2b|3GA-3a|3GA-3b|4GA-1A|4GA-1b"
; get the schedule for Fweek until Uweek
$Fweek = 1
$Uweek = 52
; subjects to ignore
$ignore = "FADE1"

; open the browser
$ieObj = _IECreate("http://www.google.com/", 0, 0, 0, 0)
$classes = StringSplit($class, "|")

; loop through classes
For $x = 1 To $classes[0]
    $class = $classes[$x]
    $file = FileOpen(@MyDocumentsDir & "\" & $class & ".ics", 2)

    If $file = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf

    FileWrite($file, "BEGIN:VCALENDAR" & @CRLF & "VERSION:1.0" & @CRLF)

    ; loop through the weeks and extract the data from the schedule while doing so
    For $i = $Fweek To $Uweek
        $Tarray = GetSchedule($class, $i, $ieObj)
        $date = _DateAdd( 'd',($i-5)*7, "2009/09/07")
        AddToSchedule($Tarray, _ArraySearch($Tarray,"Monday"), _ArraySearch($Tarray,"Tuesday"), $date, $file, $ignore)
        $date = _DateAdd( 'd',1+($i-5)*7, "2009/09/07")
        AddToSchedule($Tarray, _ArraySearch($Tarray,"Tuesday"), _ArraySearch($Tarray,"Wednesday"), $date, $file, $ignore)
        $date = _DateAdd( 'd',2+($i-5)*7, "2009/09/07")
        AddToSchedule($Tarray, _ArraySearch($Tarray,"Wednesday"), _ArraySearch($Tarray,"Thursday"), $date, $file, $ignore)
        $date = _DateAdd( 'd',3+($i-5)*7, "2009/09/07")
        AddToSchedule($Tarray, _ArraySearch($Tarray,"Thursday"), _ArraySearch($Tarray,"Friday"), $date, $file, $ignore)
        $date = _DateAdd( 'd',4+($i-5)*7, "2009/09/07")
        AddToSchedule($Tarray, _ArraySearch($Tarray,"Friday"), UBound($Tarray)-6, $date, $file, $ignore)
    Next

    FileWrite($file, "END:VCALENDAR")
    FileClose($file)

    ; ftp login information
    $server = '*****'
    $username = '*****'
    $pass = '*****'
    $ftpfolder = '*****'

    ; use ncftp to upload the file to a host server
    $o = RunWait('"ncftpput.exe" -u "' & $username & '" -p "' & $pass & '" "' & $server & '" "' & $ftpfolder & '" "' & @MyDocumentsDir & '\'& $class & '.ics"', "", @SW_HIDE)
    If $o <> 0 Then MsgBox(0,"Error!", "The program encountered an error: " & $o)

    FileDelete(@MyDocumentsDir & "\" & $class & ".ics")
Next

; close browser
_IEQuit($ieObj)

Exit

; here the data is formated and written to the file
Func AddToSchedule($Aarray, $Astart, $Aend, $Adate, $Afile, $Aignore)
    $Bignore = StringSplit($Aignore, "|", 2)
    For $t = $Astart+1 To $Aend Step 6
        $beginTa = StringSplit($Aarray[$t], ":", 2)
        If UBound($beginTa) <> 2 Then ExitLoop
        If StringLen($beginTa[0]) = 1 Then $beginTa[0] = "0"& $beginTa[0]
        If StringLen($beginTa[1]) = 1 Then $beginTa[1] = "0"& $beginTa[1]
        $beginT = StringReplace($Adate, "/", "") & "T" & $beginTa[0] & $beginTa[1] & "00"

        $endTa = StringSplit($Aarray[$t+1], ":", 2)
        If StringLen($endTa[0]) = 1 Then $endTa[0] = "0"& $endTa[0]
        If StringLen($endTa[1]) = 1 Then $endTa[1] = "0"& $endTa[1]
        $endT = StringReplace($Adate, "/", "") & "T" & $endTa[0] & $endTa[1] & "00"

        $subT = $Aarray[$t+2]
        $locT = $Aarray[$t+3]
        $teachT = $Aarray[$t+4]
        $weekT = $Aarray[$t+5]

        For $r = 0 To UBound($Bignore)-1
            If StringInStr($subT, $Bignore[$r]) <> 0 Then ContinueLoop 2
        Next

        FileWrite($Afile, "BEGIN:VEVENT" & @CRLF)
        FileWrite($Afile, "UID:" & Binary($beginT & "-" & $endT & "-" & $locT) & @CRLF)
        FileWrite($Afile, "DTSTART:" & $beginT & @CRLF)
        FileWrite($Afile, "DTEND:" & $endT & @CRLF)
        FileWrite($Afile, "LOCATION;ENCODING=QUOTED-PRINTABLE:" & $locT & @CRLF)
        FileWrite($Afile, "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" & "Teacher: " & $teachT & " Weeks: " & $weekT & @CRLF)
        FileWrite($Afile, "SUMMARY;ENCODING=QUOTED-PRINTABLE:" & $subT & @CRLF)
        FileWrite($Afile, "END:VEVENT" & @CRLF)
    Next
EndFunc

; here the schedule is extracted from the school website
Func GetSchedule($class, $week, $ieObj)
_IENavigate($ieObj, "http://194.171.178.25:8080/Reporting/Textspreadsheet;Student%20Sets;name;" & $class & "?&weeks=" & $week & "&days=1-5&width=0&height=0", 1)
$text = _IEDocReadHTML($ieObj)
$result = StringInStr($text, "Monday")
$text = StringTrimLeft($text, $result-1)
$result = StringInStr($text, "Tuesday")

$result = StringInStr($text, "<TABLE class=footer-border-args")
$text = StringTrimRight($text, StringLen($text)-$result+1)

$text = StringReplace($text, "</BODY>", "")
$text = StringReplace($text, "</HTML>", "")
$text = StringReplace($text, "<TBODY>", "")
$text = StringReplace($text, "</TBODY>", "")
$text = StringReplace($text, "<SPAN>", "")
$text = StringReplace($text, "</SPAN>", "")
$text = StringReplace($text, "<SPAN class=labelone>", "")
$text = StringReplace($text, "<COLGROUP>", "")
$text = StringReplace($text, "<P>", "")
$text = StringReplace($text, "</P>", "")
$text = StringReplace($text, "<TD>", "")
$text = StringReplace($text, "</TD>", "")
$text = StringReplace($text, "<TR>", "")
$text = StringReplace($text, "</TR>", "")
$text = StringReplace($text, "<TABLE class=spreadsheet border=t cellSpacing=0 cellPadding=2>", "")
$text = StringReplace($text, "</TABLE>", "")
$text = StringReplace($text, "<COL class=column0>", "")
$text = StringReplace($text, "<COL class=column1>", "")
$text = StringReplace($text, "<COL class=column2>", "")
$text = StringReplace($text, "<COL class=column3>", "")
$text = StringReplace($text, "<COL class=column4>", "")
$text = StringReplace($text, "<COL class=column5>", "")
$text = StringReplace($text, "<TR class=columnTitles>", "")
$text = StringReplace($text, "Begin", "")
$text = StringReplace($text, "Eind", "")
$text = StringReplace($text, "Activiteit", "")
$text = StringReplace($text, "Plaats", "")
$text = StringReplace($text, "Docent(en)", "")
$text = StringReplace($text, "Kalenderweken", "")

$text = StringStripWS($text,4)

$Tarray = StringSplit($text, @CR, 2)
Return $Tarray
EndFunc

Again if anyone has ideas to speed this up a bit I'd like to hear, thanks in advance! :

ps: just typing this gave me a good idea, somehow reduce the number of weeks I need to get from the site. That should speed things up a bit.

Other suggestions are still welcome though :D

Edited by CyberneticSoldier
Link to comment
Share on other sites

Thanks dantay9 :D It does seem a lot faster now. But now I have to change the "strip useless stuff" part again because _InetGetSource returns things differently (I don't know why, but there seems to be much less code on the webpage or it's formatted very differently).

Well I changed the code a bit:

#include <Date.au3>
#include <Array.au3>
#include <INet.au3>

$class = "1GA-1a|1GA-1b|1GA-2a|1GA-2b|1GA-3a|1GA-3b|1GA-4a|1GA-4b|1GA-5a|1GA-5b|1GA-6|1GA-7|2GA-1a|2GA-1b|2GA-2a|2GA-2b|3GA-1a|3GA-1b|3GA-2a|3GA-2b|3GA-3a|3GA-3b|4GA-1A|4GA-1b"
$Fweek = 3
$Uweek = 52
$ignore = "FADE1"

$classes = StringSplit($class, "|")

For $x = 1 To $classes[0]
    $class = $classes[$x]
    $file = FileOpen(@MyDocumentsDir & "\" & $class & ".ics", 2)

    If $file = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf

    FileWrite($file, "BEGIN:VCALENDAR" & @CRLF & "VERSION:1.0" & @CRLF)

    For $i = $Fweek To $Uweek
        $Tarray = GetSchedule($class, $i)
        $date = _DateAdd( 'd',($i-5)*7, "2009/09/07")
        AddToSchedule($Tarray, _ArraySearch($Tarray,"Monday"), _ArraySearch($Tarray,"Tuesday"), $date, $file, $ignore)
        $date = _DateAdd( 'd',1+($i-5)*7, "2009/09/07")
        AddToSchedule($Tarray, _ArraySearch($Tarray,"Tuesday"), _ArraySearch($Tarray,"Wednesday"), $date, $file, $ignore)
        $date = _DateAdd( 'd',2+($i-5)*7, "2009/09/07")
        AddToSchedule($Tarray, _ArraySearch($Tarray,"Wednesday"), _ArraySearch($Tarray,"Thursday"), $date, $file, $ignore)
        $date = _DateAdd( 'd',3+($i-5)*7, "2009/09/07")
        AddToSchedule($Tarray, _ArraySearch($Tarray,"Thursday"), _ArraySearch($Tarray,"Friday"), $date, $file, $ignore)
        $date = _DateAdd( 'd',4+($i-5)*7, "2009/09/07")
        AddToSchedule($Tarray, _ArraySearch($Tarray,"Friday"), UBound($Tarray)-6, $date, $file, $ignore)
    Next

    FileWrite($file, "END:VCALENDAR")
    FileClose($file)
Next

$server = '****'
$username = '****'
$pass = '****'
$ftpfolder = '****'
$upload = ""

For $x = 1 To $classes[0]
    $class = $classes[$x]
    $upload = $upload & '"' & @MyDocumentsDir & '\'& $class & '.ics" '
Next

$o = RunWait('"ncftpput.exe" -u "' & $username & '" -p "' & $pass & '" "' & $server & '" "' & $ftpfolder & '" ' & $upload, "", @SW_HIDE)
If $o <> 0 Then MsgBox(0,"Error!", "The program encountered an error: " & $o)

For $x = 1 To $classes[0]
    $class = $classes[$x]
    FileDelete(@MyDocumentsDir & "\" & $class & ".ics")
Next

Exit

Func AddToSchedule($Aarray, $Astart, $Aend, $Adate, $Afile, $Aignore)
    $Bignore = StringSplit($Aignore, "|", 2)
    For $t = $Astart+1 To $Aend Step 6
        $beginTa = StringSplit($Aarray[$t], ":", 2)
        If UBound($beginTa) <> 2 Then ExitLoop
        If StringLen($beginTa[0]) = 1 Then $beginTa[0] = "0"& $beginTa[0]
        If StringLen($beginTa[1]) = 1 Then $beginTa[1] = "0"& $beginTa[1]
        $beginT = StringReplace($Adate, "/", "") & "T" & $beginTa[0] & $beginTa[1] & "00"

        $endTa = StringSplit($Aarray[$t+1], ":", 2)
        If StringLen($endTa[0]) = 1 Then $endTa[0] = "0"& $endTa[0]
        If StringLen($endTa[1]) = 1 Then $endTa[1] = "0"& $endTa[1]
        $endT = StringReplace($Adate, "/", "") & "T" & $endTa[0] & $endTa[1] & "00"

        $subT = $Aarray[$t+2]
        $locT = $Aarray[$t+3]
        $teachT = $Aarray[$t+4]
        $weekT = $Aarray[$t+5]

        For $r = 0 To UBound($Bignore)-1
            If StringInStr($subT, $Bignore[$r]) <> 0 Then ContinueLoop 2
        Next

        FileWrite($Afile, "BEGIN:VEVENT" & @CRLF)
        FileWrite($Afile, "UID:" & Binary($beginT & "-" & $endT & "-" & $locT) & @CRLF)
        FileWrite($Afile, "DTSTART:" & $beginT & @CRLF)
        FileWrite($Afile, "DTEND:" & $endT & @CRLF)
        FileWrite($Afile, "LOCATION;ENCODING=QUOTED-PRINTABLE:" & $locT & @CRLF)
        FileWrite($Afile, "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" & "Teacher: " & $teachT & " Weeks: " & $weekT & @CRLF)
        FileWrite($Afile, "SUMMARY;ENCODING=QUOTED-PRINTABLE:" & $subT & @CRLF)
        FileWrite($Afile, "END:VEVENT" & @CRLF)
    Next
EndFunc

Func GetSchedule($class, $week)
$text = _InetGetSource("http://194.171.178.25:8080/Reporting/Textspreadsheet;Student%20Sets;name;" & $class & "?&weeks=" & $week & "&days=1-5&width=0&height=0")
$result = StringInStr($text, "Monday")
$text = StringTrimLeft($text, $result-1)
$result = StringInStr($text, "Friday")

$result = StringInStr($text, "<table",0,2,$result)
$text = StringTrimRight($text, StringLen($text)-$result+1)

While 1
    $result = StringInStr($text, "<")
    $result2 = StringInStr($text, ">",0,1,$result)
    If $result == 0 Then ExitLoop
    $text = StringReplace($text,StringMid($text,$result,$result2-$result+1),"")
WEnd

$text = StringReplace($text, "Begin", "")
$text = StringReplace($text, "Eind", "")
$text = StringReplace($text, "Activiteit", "")
$text = StringReplace($text, "Plaats", "")
$text = StringReplace($text, "Docent(en)", "")
$text = StringReplace($text, "Kalenderweken", "")

$text = StringStripWS($text,4)
$Tarray = StringSplit($text, @CR, 2)
Return $Tarray
EndFunc

According to AU3Profiler most of the time is now in the GetSchedule function and in the upload. Appearently _InetGetSource takes almost no time at all, but I can't really imagine that all the string functions in GetSchedule take more time then _InetGetSource... and if they do I don't think I can optimize much there. I guess I'll try to find a way to limit the number of weeks down to something reasonable, as the amount of those seem to be pretty much the only area I can optimize now.

btw, I also got a pm from someone that says it might be a good idea to ask my school to provide this service. That thought also crossed my mind, but as the ICT department is taking ages to act on even the simplest of problems I can only expect this to take even longer as it's not even a real problem. I will ask the ICT department at school, but I'm not going to expect them to have this service soon, so for now my service will at least serve as a temporary solution.

Edited by CyberneticSoldier
Link to comment
Share on other sites

Well in the search of more speed I decided to try some simple multi threading/tasking/whatever. So I split the script up into two parts. A master script and a child script.

The master script initializes the child script a number of times (equal to the amount of classes) and after that uploads the schedules and deletes them locally.

The child script gets the schedule for a single class and stores it locally.

The master script:

TraySetToolTip("Preparing variables...")

$class = "1GA-1a|1GA-1b|1GA-2a|1GA-2b|1GA-3a|1GA-3b|1GA-4a|1GA-4b|1GA-5a|1GA-5b|1GA-6|1GA-7|2GA-1a|2GA-1b|2GA-2a|2GA-2b|3GA-1a|3GA-1b|3GA-2a|3GA-2b|3GA-3a|3GA-3b|4GA-1A|4GA-1b"
$Fweek = 3
$Uweek = 52
$ignore = "FADE1"

$classes = StringSplit($class, "|")

TraySetToolTip("Variables prepared, start retrieving schedules.")

For $i = 1 to $classes[0]
    Run('NHTV_rooster_get.exe ' & $classes[$i] & ' ' & $Fweek & ' ' & $Uweek & ' ' & $ignore)
Next

TraySetToolTip("Schedule retrieving started.")

While 1
    $q = 0
    For $x = 1 To $classes[0]
        $class = $classes[$x]
        If FileExists(@MyDocumentsDir & "\" & $class & ".ics") Then $q = $q + 1
    Next
    If $q = $classes[0] Then ExitLoop
    TraySetToolTip(Round(100/$classes[0]*$q) & "% of schedules retrieved.")
WEnd

TraySetToolTip("All schedules retrieved, starting upload.")

$server = '*****'
$username = '*****'
$pass = '*****'
$ftpfolder = '*****'
$upload = ""

For $x = 1 To $classes[0]
    $class = $classes[$x]
    $upload = $upload & '"' & @MyDocumentsDir & '\'& $class & '.ics" '
Next

TraySetToolTip("Uploading...")

$o = RunWait('"ncftpput.exe" -u "' & $username & '" -p "' & $pass & '" "' & $server & '" "' & $ftpfolder & '" ' & $upload, "", @SW_HIDE)
If $o <> 0 Then MsgBox(0,"Error!", "The program encountered an error: " & $o)

TraySetToolTip("Upload done, removing local files.")

For $x = 1 To $classes[0]
    $class = $classes[$x]
    FileDelete(@MyDocumentsDir & "\" & $class & ".ics")
Next

TraySetToolTip("Local files removed, shutting down.")
Exit

The child script (build and named: NHTV_rooster_get.exe):

#NoTrayIcon
#include <Date.au3>
#include <Array.au3>
#include <INet.au3>

$data = StringSplit($CmdLineRaw, ' ', 1)

$class = $data[1]
$Fweek = $data[2]
$Uweek = $data[3]
$ignore = $data[4]

$file = FileOpen(@MyDocumentsDir & "\" & $class & "._temp", 2)

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file, "BEGIN:VCALENDAR" & @CRLF & "VERSION:1.0" & @CRLF)

For $i = $Fweek To $Uweek
    $Tarray = GetSchedule($class, $i)
    $date = _DateAdd( 'd',($i-5)*7, "2009/09/07")
    AddToSchedule($Tarray, _ArraySearch($Tarray,"Monday"), _ArraySearch($Tarray,"Tuesday"), $date, $file, $ignore)
    $date = _DateAdd( 'd',1+($i-5)*7, "2009/09/07")
    AddToSchedule($Tarray, _ArraySearch($Tarray,"Tuesday"), _ArraySearch($Tarray,"Wednesday"), $date, $file, $ignore)
    $date = _DateAdd( 'd',2+($i-5)*7, "2009/09/07")
    AddToSchedule($Tarray, _ArraySearch($Tarray,"Wednesday"), _ArraySearch($Tarray,"Thursday"), $date, $file, $ignore)
    $date = _DateAdd( 'd',3+($i-5)*7, "2009/09/07")
    AddToSchedule($Tarray, _ArraySearch($Tarray,"Thursday"), _ArraySearch($Tarray,"Friday"), $date, $file, $ignore)
    $date = _DateAdd( 'd',4+($i-5)*7, "2009/09/07")
    AddToSchedule($Tarray, _ArraySearch($Tarray,"Friday"), UBound($Tarray)-6, $date, $file, $ignore)
Next

FileWrite($file, "END:VCALENDAR")
FileClose($file)

FileMove(@MyDocumentsDir & "\" & $class & "._temp", @MyDocumentsDir & "\" & $class & ".ics", 1)

Exit

Func AddToSchedule($Aarray, $Astart, $Aend, $Adate, $Afile, $Aignore)
    $Bignore = StringSplit($Aignore, "|", 2)
    For $t = $Astart+1 To $Aend Step 6
        $beginTa = StringSplit($Aarray[$t], ":", 2)
        If UBound($beginTa) <> 2 Then ExitLoop
        If StringLen($beginTa[0]) = 1 Then $beginTa[0] = "0"& $beginTa[0]
        If StringLen($beginTa[1]) = 1 Then $beginTa[1] = "0"& $beginTa[1]
        $beginT = StringReplace($Adate, "/", "") & "T" & $beginTa[0] & $beginTa[1] & "00"

        $endTa = StringSplit($Aarray[$t+1], ":", 2)
        If StringLen($endTa[0]) = 1 Then $endTa[0] = "0"& $endTa[0]
        If StringLen($endTa[1]) = 1 Then $endTa[1] = "0"& $endTa[1]
        $endT = StringReplace($Adate, "/", "") & "T" & $endTa[0] & $endTa[1] & "00"

        $subT = $Aarray[$t+2]
        $locT = $Aarray[$t+3]
        $teachT = $Aarray[$t+4]
        $weekT = $Aarray[$t+5]

        For $r = 0 To UBound($Bignore)-1
            If StringInStr($subT, $Bignore[$r]) <> 0 Then ContinueLoop 2
        Next

        FileWrite($Afile, "BEGIN:VEVENT" & @CRLF)
        FileWrite($Afile, "UID:" & Binary($beginT & "-" & $endT & "-" & $locT) & @CRLF)
        FileWrite($Afile, "DTSTART:" & $beginT & @CRLF)
        FileWrite($Afile, "DTEND:" & $endT & @CRLF)
        FileWrite($Afile, "LOCATION;ENCODING=QUOTED-PRINTABLE:" & $locT & @CRLF)
        FileWrite($Afile, "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" & "Teacher: " & $teachT & " Weeks: " & $weekT & @CRLF)
        FileWrite($Afile, "SUMMARY;ENCODING=QUOTED-PRINTABLE:" & $subT & @CRLF)
        FileWrite($Afile, "END:VEVENT" & @CRLF)
    Next
EndFunc

Func GetSchedule($class, $week)
$text = _InetGetSource("http://194.171.178.25:8080/Reporting/Textspreadsheet;Student%20Sets;name;" & $class & "?&weeks=" & $week & "&days=1-5&width=0&height=0")
$result = StringInStr($text, "Monday")
$text = StringTrimLeft($text, $result-1)
$result = StringInStr($text, "Friday")

$result = StringInStr($text, "<table",0,2,$result)
$text = StringTrimRight($text, StringLen($text)-$result+1)

While 1
    $result = StringInStr($text, "<")
    $result2 = StringInStr($text, ">",0,1,$result)
    If $result == 0 Then ExitLoop
    $text = StringReplace($text,StringMid($text,$result,$result2-$result+1),"")
WEnd

$text = StringReplace($text, "Begin", "")
$text = StringReplace($text, "Eind", "")
$text = StringReplace($text, "Activiteit", "")
$text = StringReplace($text, "Plaats", "")
$text = StringReplace($text, "Docent(en)", "")
$text = StringReplace($text, "Kalenderweken", "")

$text = StringStripWS($text,4)
$Tarray = StringSplit($text, @CR, 2)
Return $Tarray
EndFunc

Just for comparison, this takes slightly less then one minute to execute. The previous version still took a few minutes to complete.

I'm too lazy to do the week limiting thing, as for some reason school weeks are not the same as calendar weeks (at least in the schedule they're not). So I would have to figure out the offset between the calendar weeks and the school weeks and use that to figure it all out. Waaaaaaay too much work. And now I really don't think it'll get much faster. Maybe I can get it down to half a minute by limiting the weeks, but that just doesn't seem worth the trouble.

Link to comment
Share on other sites

The only way I can see your script getting any faster is by starting the upload with FTP while some of the NHTV_rooster_get.exe programs are still running.

Edit: Why don't you put the responsibility of uploading on the child processes. That way they can start as soon as there is a file ready for uploading .. Or are you not allowed to open multiple connections?

Edited by Manadar
Link to comment
Share on other sites

  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...