Jump to content

Recommended Posts

Posted

Hello again,

I looking for fast possible way to insert single line to EditBox GuiCtrlCreateEdit.

BeginUpdate -> set data -> endUpdate cant be used!

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $msg, $diff, $time, $hEdit
    GUICreate("My GUI", 400, 250)
    $hEdit = GUICtrlCreateEdit("", 0, 0, 400, 150)
    GUISetState()

    $time = TimerInit()
    For $i = 1 To 100
    GUICtrlSetData($hEdit, "GUICtrlSetData" & @CRLF, 1)
    Next
    $diff = Int(TimerDiff($time) * 100)/100
    GUICtrlCreateLabel("GUICtrlSetData: " & $diff & "ms", 10, 170)

    $time = TimerInit()
    For $i = 1 To 100
    GUICtrlSendMsg($hEdit, 0xC2, 0, "GUICtrlSendMsg $EM_REPLACESEL" & @CRLF)
    Next
    $diff = Int(TimerDiff($time) * 100)/100
    GUICtrlCreateLabel("GUICtrlSendMsg: " & $diff & "ms", 10, 190)

    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

EndFunc   ;==>Example

 

Posted

Begin/End can be used!

Fair comparison:

___Example()

Func ___Example()
    Local $msg, $diff, $time, $hEdit
    GUICreate("My GUI", 400, 260)
    $hEdit = GUICtrlCreateEdit("", 0, 0, 400, 150)
    GUISetState()

    $time = TimerInit()
    _GUICtrlEdit_BeginUpdate($hEdit)
    For $i = 1 To 100
        GUICtrlSetData($hEdit, "GUICtrlSetData" & @CRLF, 1)
    Next
    _GUICtrlEdit_EndUpdate($hEdit)
    $diff = TimerDiff($time) / 100
    GUICtrlCreateLabel("Raw GUICtrlSetData: " & $diff & "ms", 10, 170)
    GUICtrlSetData($hEdit, "")      ; clear content

    $time = TimerInit()
    _GUICtrlEdit_BeginUpdate($hEdit)
    For $i = 1 To 100
        GUICtrlSetData($hEdit, "GUICtrlSetData" & @CRLF, 1)
    Next
    _GUICtrlEdit_EndUpdate($hEdit)
    $diff = TimerDiff($time) / 100
    GUICtrlCreateLabel("GUICtrlSetData with Begin/End: " & $diff & "ms", 10, 190)
    GUICtrlSetData($hEdit, "")      ; clear content

    $time = TimerInit()
    _GUICtrlEdit_BeginUpdate($hEdit)
    Local $s
    For $i = 1 To 100
        $s &= "GUICtrlSetData" & @CRLF
    Next
    GUICtrlSetData($hEdit, $s)
    _GUICtrlEdit_EndUpdate($hEdit)
    $diff = TimerDiff($time) / 100
    GUICtrlCreateLabel("Block GUICtrlSetData: " & $diff & "ms", 10, 210)
    GUICtrlSetData($hEdit, "")      ; clear content

    $time = TimerInit()
    For $i = 1 To 100
        GUICtrlSendMsg($hEdit, 0xC2, 0, "GUICtrlSendMsg $EM_REPLACESEL" & @CRLF)
    Next
    $diff = TimerDiff($time) / 100
    GUICtrlCreateLabel("GUICtrlSendMsg: " & $diff & "ms", 10, 230)

    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>___Example

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

@jchd

You make an huuuge mistake here:

$diff = TimerDiff($time) / 100

 

My goal is to make chat Console for TCP client so after adding new line script should fast as possible back to received message loop.

Posted (edited)

Ok my previous was not exactly fair, but it is still the fastest :

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>

Example()

Func Example()
  Local $msg, $diff, $time
  Global $hGUI = GUICreate("My GUI", 400, 250)
  Global $hEdit = GUICtrlCreateEdit("", 0, 0, 400, 150)
  GUISetState()

  $time = TimerInit()
  For $i = 1 To 100
    GUICtrlSetData($hEdit, "GUICtrlSetData" & @CRLF, 1)
  Next
  $diff = int(TimerDiff($time))
  GUICtrlCreateLabel("GUICtrlSetData: " & $diff & "ms", 10, 170)

  $time = TimerInit()
  For $i = 1 To 100
    GUICtrlSendMsg($hEdit, 0xC2, 0, "GUICtrlSendMsg $EM_REPLACESEL" & @CRLF)
  Next
  $diff = Int(TimerDiff($time))
  GUICtrlCreateLabel("GUICtrlSendMsg: " & $diff & "ms", 10, 190)

  $time = TimerInit()
  For $i = 1 To 100
    AddText ("ControlSetText" & @CRLF)
  Next
  $diff = Int(TimerDiff($time))
  GUICtrlCreateLabel("ControlSetText: " & $diff & "ms", 10, 210)

  $time = TimerInit()
  For $i = 1 To 100
    _GUICtrlEdit_AppendText ($hEdit, "AppendText" & @CRLF)
  Next
  $diff = Int(TimerDiff($time))
  GUICtrlCreateLabel("AppendText: " & $diff & "ms", 10, 230)

  While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
  WEnd

EndFunc   ;==>Example

Func AddText ($sTxt)
  Local Static $sEditText
  $sEditText &= $sTxt
  ControlSetText ($hGUI, "", $hEdit, $sEditText)
EndFunc

So far...

Edited by Nine
Posted

Guys make tests on this example is more realistic in my case. Try to speed up it.

Example()


Func Example()

    Local $hGUI, $hEdit, $hButton, $hLabel, $time, $diff

    $hGUI = GUICreate("Test", 500, 500)
    $hEdit = GUICtrlCreateEdit("", 10, 10, 400, 400, 2099200)
    $hButton = GUICtrlCreateButton("Add", 10, 450, 80, 30)
    $hLabel = GUICtrlCreateLabel("", 10, 420, 100, 20)

    GUISetState()

    For $i = 1 To 100
        GUICtrlSetData($hEdit, "Example add new line with some text bla bla bah" & @CRLF, 1)
    Next

    GUICtrlSendMsg($hEdit, 0xB1, 9999, 9999)

    While 1

        Switch GUIGetMsg()
            Case -3
                Exit
            Case $hButton
                $time = TimerInit()
                GUICtrlSetData($hEdit, "Example add new line with some text bla bla bah" & @CRLF, 1)
                $diff = TimerDiff($time)
                GUICtrlSetData($hLabel, "Time: " & Int($diff * 100)/ 100 & "ms")
        EndSwitch

    WEnd

EndFunc

 

Posted (edited)

The bigger the buffer that holds data the longer it will take = make $hEdit smaller in size and notice a speed up

Edited by Deye
Posted (edited)
3 hours ago, Ascer said:

You make an huuuge mistake here:

Which "huge mistake" please?

That's the time in ms used for inserting a line and displaying it.

Your * 100 / 100 is a no-op.

And I'd say something like 2.2 ms (on my old PC) is perfectly negligible.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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
  • Recently Browsing   0 members

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