Jump to content

Script becomes way slower after a msgbox - (Moved)


Recommended Posts

  • Developers

I understand but you have to see this a little in perspective as the loop currently really doesn't do anything and, like you said, when for some reason extra things need to be checked by this single threaded process, the efficiency is bound to become less.

Simple example that makes the factor 2 for me:

$x = 0
$start = TimerInit()
For $i = 1 To 500000
    $x = WinGetHandle("[ACTIVE]")
Next
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TimerDiff($start) = ' & TimerDiff($start) & @CRLF) ;### Debug Console
; Show AutoIt3's hidden window
WinSetState(AutoItWinGetTitle(), "", @SW_SHOW)
$start = TimerInit()
$x = 0
For $i = 1 To 500000
    $x = WinGetHandle("[ACTIVE]")
Next
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TimerDiff($start) = ' & TimerDiff($start) & @CRLF) ;### Debug Console

Agreed it is still substantial, but this was merely to counter the 600% to 1000% and put that in perspective. 
I would not know myself how I could debug this so there is no other option than to wait for @Jon unless @jpm knows how to tackle this.

Jos 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I am nowhere comparing AutoIt speed with C++ or any other languages.  I am comparing AutoIt with itself.  It should be as fast on any Windows version.  I have no problem with GuiOnEventMode as it is comparable between 7 and 10.  But the GUI speed issue is definitely not trivial.  I would love to give you a hand on solving this, but I am not sure I would be able to help.

Link to comment
Share on other sites

The only way out is debug-compile the source and step-debug compare a W7 example against the same under W10 in two bare-bones virtual machines.  valgrind could also greatly help.

Here we're hopelessly impotent.

Of course this issue won't prematurely trigger turning the sun into a red giant, but still.

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)

Link to comment
Share on other sites

On 4/2/2020 at 11:12 AM, Nine said:

Confirmed.  on Win10 the scale is similar as yours 10x slower after the MsgBox.

$x=0
$start=TimerInit()
for $i=1 to 500000
    $x+=1
Next
$start = Round(TimerDiff($start), 5)
ConsoleWrite('Round 1 = ' & $start & @CRLF)
MsgBox(0,"",$start) ; Round 1 = 58.10089

$start=TimerInit()
$x=0
for $i=1 to 500000
    $x+=1
Next
$start = Round(TimerDiff($start), 5)
ConsoleWrite('Round 2 = ' & $start & @CRLF)
MsgBox(0,"",$start) ; Round 2 = 56.70231

maybe a hardware thing ?, no clue. I can not replicate the issue.

Edit 1: same goes with the WinGetHandle

$x = 0
$start = TimerInit()
For $i = 1 To 500000
    $x = WinGetHandle("[ACTIVE]")
Next
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TimerDiff($start) = ' & TimerDiff($start) & @CRLF) ;### Debug Console
; Show AutoIt3's hidden window
WinSetState(AutoItWinGetTitle(), "", @SW_SHOW)
$start = TimerInit()
$x = 0
For $i = 1 To 500000
    $x = WinGetHandle("[ACTIVE]")
Next
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TimerDiff($start) = ' & TimerDiff($start) & @CRLF) ;### Debug Console

;@@ Debug(25) : TimerDiff($start) = 909.692171252823
;@@ Debug(33) : TimerDiff($start) = 825.419178988507

Edit 2: 

For $n = 0 To 1
    AutoItSetOption('GUIOnEventMode', $n)
    $x = 0
    $start = TimerInit()
    For $i = 1 To 500000
        $x += 1
    Next
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TimerDiff($start) = ' & TimerDiff($start) & @TAB & ' GUIOnEventMode = ' & $n & @CRLF) ;### Debug Console
    ; Show the AutoIt3 hidden window
    WinSetState(AutoItWinGetTitle(), "", @SW_SHOW)
    $start = TimerInit()
    $x = 0
    For $i = 1 To 500000
        $x += 1
    Next
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TimerDiff($start) = ' & TimerDiff($start) & @TAB & ' GUIOnEventMode = ' & $n & @CRLF) ;### Debug Console
Next
;@@ Debug(44) : TimerDiff($start) = 58.4976299233912     GUIOnEventMode = 0
;@@ Debug(52) : TimerDiff($start) = 56.4975617675848     GUIOnEventMode = 0
;@@ Debug(44) : TimerDiff($start) = 143.726465813906     GUIOnEventMode = 1
;@@ Debug(52) : TimerDiff($start) = 143.86776443691  GUIOnEventMode = 1

As far as OnEvent, it does have an impact.

Edit 3: 

$nStart = TimerInit()
$iX = 0
For $i = 1 To 500000
    $iX += 1
Next
ConsoleWrite("Initial: " & TimerDiff($nStart) & @CRLF)
$hGUI = GUICreate("Test", 10, 10)
$nStart = TimerInit()
$iX = 0
For $i = 1 To 500000
    $iX += 1
Next
ConsoleWrite("Created: " & TimerDiff($nStart) & @CRLF)
GUISetState(@SW_HIDE)
$nStart = TimerInit()
$iX = 0
For $i = 1 To 500000
    $iX += 1
Next
ConsoleWrite("Hidden: " & TimerDiff($nStart) & @CRLF)
GUISetState(@SW_SHOW)
$nStart = TimerInit()
$iX = 0
For $i = 1 To 500000
    $iX += 1
Next
ConsoleWrite("Shown: " & TimerDiff($nStart) & @CRLF)
;Initial: 57.5254399859034
;Created: 56.5734751454337
;Hidden: 58.4333529027309
;Shown: 58.930668644478

It all look good in my PC. I guess that to debug this we are gonna have to share every detail of the PC environment ( software and hardware ). 

Edit 5: ..tried on other PCs. The one that shows these bugs have Hyper-V running.
Edit 6: is not the Hyper-V, as I just remoted in to a PC just like the one I have at home but running Hyper-V and it showed none of the problems.

Sorry about all these edits but I'm trying to find the reason that produces the events/mishaps. 

 

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Thanks for the reality check pointing to hardware and/or drivers and/or OSversion, that's a big step toward pinpointing the culprit.

I'm afraid then that it won't be so easy to do due to the vast diversity of platforms.

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)

Link to comment
Share on other sites

  • Moderators

argumentum,

Are you running Win10 x32 or x64? 

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

My results:

Test1:
Round 1 = 112.6326
Round 2 = 113.9268

Test2:
@@ Debug(25) : TimerDiff($start) = 1447.3477
@@ Debug(33) : TimerDiff($start) = 1355.7156

Test 3:
@@ Debug(50) : TimerDiff($start) = 110.05     GUIOnEventMode = 0
@@ Debug(58) : TimerDiff($start) = 110.5822     GUIOnEventMode = 0
@@ Debug(50) : TimerDiff($start) = 226.943     GUIOnEventMode = 1
@@ Debug(58) : TimerDiff($start) = 226.5295     GUIOnEventMode = 1

Test 4:
Initial: 123.4077
Created: 110.2741
Hidden: 118.9294
Shown: 123.3573

Can we create a script that grabs all information needed to find the cause of this performance problem (WMI created from Scriptomatic comes to my mind)?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Check this out:

 

$x=0
$start=TimerInit()
for $i=1 to 500000
    $x+=1
Next

ConsoleWrite(TimerDiff($start) & @CRLF)
_ThreadStart("_Thread")

$start=TimerInit()
$x=0
for $i=1 to 500000
    $x+=1
Next

ConsoleWrite(TimerDiff($start) & @CRLF)

Func _Thread($vDummy)
    MsgBox(0, "", '', 1)
EndFunc   ;==>_Thread1

Func _ThreadStart($sFunctionName)
    Local $h1, $h2, $h3 = DllStructCreate("hwnd[1]"), $h4 = DllStructGetPtr($h3)
    
    $h1 = DllCallbackRegister($sFunctionName, "int", "int")
    $st = DllStructCreate("int")
    $h3 = DllCall("Kernel32.dll", "hwnd", "CreateThread", "ptr", 0, _
            "int", 0, _
            "ptr", DllCallbackGetPtr($h1), _
            "int", 0, _
            "int", 0, _
            "ptr", DllStructGetPtr($h2))
    
    DllStructSetData($h3, 1, $h3[0], 1)
    DllCall("Kernel32.dll", "int", "CloseHandle", "hwnd", DllStructGetData($h3, 1, 1))
EndFunc   ;==>_ThreadStart

After the thread starts the second results (for me) even faster than the first one...

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

2 hours ago, Melba23 said:

Are you running Win10 x32 or x64? 

Win10 x64 but I run AutoIt in x86 ( I don't run or compile x64 unless needed ) 

Edit: Just run all the examples as x64 and x86. No problems.

Edit 2: ..also changed my High Contrast theme to regular theme, back and forth. All good. 

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

It is kind of odd that everyone sees the problem except you @argumentum.  You must have unique setup.  It would be great if you could change your setup to get the same result of us, and pinpoint the setup solution that makes you invincible...

Link to comment
Share on other sites

I too do not see the problem based on argumentum‘s scripts. I posted my results above. 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

1 minute ago, argumentum said:

That is it, 1909 has the issue, 1607 does not. I would have to make virtual PCs, with every mayor version to find exactly when it started. But I rather not unless needed.

That is a great finding, hope it will help to solve the issue.  Thanks a lot.  I don,t think it is necessary to find WHEN exactly it has started.  Now the problem is to find out WHY ?

Link to comment
Share on other sites

I run Windows 10 Enterprise, Version 10.0.17134 Build 17134 (HAL 1098)

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

16 minutes ago, Nine said:

we already know that since long.  Maybe read the whole thread ?

I did, and i didn't sow anything like those results.

I am just trying to find a solution since i know about this issue long time ago.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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