Jump to content

Speed it up


McGod
 Share

Recommended Posts

Alright, I have a Save function. though its REALLY slow, 7454 milliseconds. I want to try to speed it up

Func save ()
$timer = timerInit ()
Local $char, $S_Saveret, $S_tablenames, $check, $S_Saveam
$char = GUICtrlRead ( $None )
If $char = "None" Then
MsgBox ( 1, "Error", "You must load a config before saving!" )
Return
EndIf
_SQLite_Query ( -1, "SELECT * FROM " & $char & "_Character", $S_Saveret )
_SQLite_FetchNames ( $S_Saveret, $S_tablenames )
_SQLite_QueryFinalize ($S_Saveret)
$i = 0
$S_Saveam = UBound ( $S_tablenames )
Dim $info[$S_Saveam]
Do
$info[$i] = GUICtrlRead ( $S_GUI[$i] )
Select
    Case $info[$i] = $GUI_CHECKED
    GUICtrlSetState ( $S_GUI[$i], "Yes" )
    Case $info[$i] = $GUI_UNCHECKED
    GUICtrlSetState ( $S_GUI[$i], "No" )
EndSelect
$check = _SQLite_Exec ( -1, "UPDATE " & $char & "_Character " & "SET " & $S_tablenames[$i] & "= '" & $info[$i] & "';" )
$i = $i + 1
Sleep (10)
Until $i = $S_Saveam
Local $G_Saveret, $G_tablenames, $G_Saveret, $G_Saveam, $info
_SQLite_Query ( -1, "SELECT * FROM " & $char & "_Advanced", $G_Saveret )
_SQLite_Fetchnames ( $G_Saveret, $G_tablenames )
_SQLite_QueryFinalize ( $G_Saveret )
$i = 0
$G_Saveam = UBound ( $G_tablenames )
Do
$info = GUICtrlRead ( $G_GUI[$i] )
If $info = $GUI_CHECKED Then
    GUICtrlSetState ( $S_GUI[$i], "Yes" )
ElseIf $info = $GUI_UNCHECKED Then
    GUICtrlSetState ( $S_GUI[$i], "No" )
EndIf
_SQLite_Exec ( -1, "UPDATE " & $char & "_Advanced " & "SET " & $G_tablenames[$i] & "= '" & $info & "';" )
$i = $i + 1
Until $i = $G_Saveam
$timed = timerDiff ( $timer )
MsgBox ( 1, "time", $timed )
If $check = $SQLite_OK Then
MsgBox ( 1, "Save", "Saved '" & $char & "' sucessfully!" )
Else
MsgBox ( 1, "Error", "Failed to save!" & @CRLF & _SQLite_ErrMsg () )
EndIf
EndFunc

Any suggestions?

Link to comment
Share on other sites

  • Moderators

Would help to know what this is for.... :P

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Would help to know what this is for.... :P

Whoops sorry.

This is a save function for a multi-config gui.

You load a config and you save it with this. It uses SQLite to store data.

Link to comment
Share on other sites

Hi,

In general, when using loops and calling sqlite, I have used sqlite3.exe and have been aware of the "overheads" with the command line calls.

2 or 3 answers;

1. I have therefore accumulated calls as strings and executed them at the end of a loop in 1 hit;

so

$_SQLite_Exec &="UPDATE " & $char & "_Character " & "SET " & $S_tablenames[$i]& "= '" & $info[$i] & "';"

ends up having a whole lot of "update" lines separated by ";"before I actually call the " _SQLite_Exec (-1,$_SQLite_Exec)"

Hope that makes sense ; I think it may apply to the speed of Piccaso's sqlite.dll version as well.

[i have not done it with his version; the command line version would certainly do it if you wanted to use that; Picasso does have that in his commands as well as an option if the dll won't take it...]

2. I think it might be possible to do a more general "UPDATE" command which uses mmore effficient SQL commands; not sure depending on your data and db structure?

3. maybe others?...

Best, Randall

Link to comment
Share on other sites

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...