Jump to content

Script is very slow in non-Win10 OS like Win8/Win7


Recommended Posts

Hi guys.

I've spent several months working on my own business selling software and I've come across a very strange and easily reproducible bug.

So basically, no matter what memory reading UDF I've used I've encountered the same bug.

So if we create a compiled exe with a for loop that runs the function below function 5,000 times it will work flawlessly and smoothly in Windows 10. But in ANY other Windows OS it lags like crazy. I've tested this on separate computers running the target OS AND by simply placing the compiled exe in compatibility mode.

You can easily test this yourself with the extremely simple script below...

All this does it read the memory 5,000 times of SciTe's window and then creates a tooltip. Now run it in windows 10 and it is fast as hell, but then set the compatibility mode to Window 8 or anything else and you'll see just how massive the performance drop is when reading the memory.

Just watch the tooltip as you move the mouse across the screen.

I thought this was simply a problem with KDmemory but I now think it is a deeper problem in AutoIt. I've tried the Beta versions of Autoit too.

I've also attached the UDF which contains the function _KDMemory_ReadProcessMemory()

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=bugtest.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include "KDMemory2.au3"
$processName = "SciTe.exe"
$processId = ProcessExists($processName)
$handles = _KDMemory_OpenProcess($processId)
HotKeySet("{END}", "Quit")
While 1
    For $i = 1 To 5000 Step 1
        $Name = _KDMemory_ReadProcessMemory($handles, 0x5fdd75e1, "Char[14]", 0)
    Next
    ToolTip($Name)
WEnd

Func Quit()
    ToolTip('')
    Exit
EndFunc   ;==>Quit

I spent an awfully long amount of time searching the net for an answer as to why performance might be so vastly different and I'm at my wits end. I've searched high and low for an answer.

KDMemory2.au3

Edited by Bizzaro
Link to comment
Share on other sites

Msgbox never appears despite only 2 loops, or regardless of memory address.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=bugtest.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include "KDMemory2.au3"
$processName = "SciTe.exe"
$processId = ProcessExists($processName)
$handles = _KDMemory_OpenProcess($processId)
HotKeySet("{END}", "Quit")

$Timer = TimerInit()
While 1
    For $i = 1 To 2 Step 1
        $Name = _KDMemory_ReadProcessMemory($handles, 0x0, "Char[14]", 0)
    Next
    ToolTip($Name)
WEnd
MsgBox(0,"Time", TimerDiff($Timer))

Func Quit()
    ToolTip('')
    Exit
EndFunc   ;==>Quit

 

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Moderators

Bizzaro,

From my tests on Win7 it looks as if the major time waster in that code is the multiple ToolTip calls:

  • 5000 calls with no ToolTip calls: TimerDiff returns .700
  • 5000 calls with a toolTip on each pass: TimerDiff returns 14.355
  • 5000 calls but only calling ToolTip if the function return changes: TimerDiff returns .750

Hence it would seem that the problem is in the ToolTip calls and not the memory UDF. Try running your script with a suitable condition like this:

$sOldTip = "XXXXXXXXXXXXXXX"

For $i = 1 To 5000
    $Name = _KDMemory_ReadProcessMemory($handles, 0x5fdd75e1, "Char[14]", 0)
    If $Name <> $sOldTip Then
        $sOldTip = $Name
        ToolTip("Result: " & $Name)
    EndIf

Next

Does that speed it up?

M23

Edit: And I am still waiting for you to explain why you need to read process memory in your script. The source of that UDF does not fill me with a lot of confidence that we should be offering you any assistance.

Edited by Melba23

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

I changed the code to remove the tooltip completely.

The script now displays a messagebox with the TimerDiff.

Even without the tooltip, the increase goes from 140 to 655 if the program is run in anything but Win10. This is without the tooltip. What i'm wondering is what changes using Win10 compatibility mode which could affect the script this way?

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=bugtest.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include "KDMemory2.au3"
$processName = "SciTe.exe"
$processId = ProcessExists($processName)
$handles = _KDMemory_OpenProcess($processId)
HotKeySet("{END}", "Quit")
Global $Timer =TimerInit()
While 1
    For $i = 1 To 5000 Step 1
        $Name = _KDMemory_ReadProcessMemory($handles, 0x5fdd75e1, "Char[14]", 0)
    Next
MsgBox(0,"Time", TimerDiff($Timer))
$Timer =TimerInit()
WEnd

Func Quit()
    ToolTip('')
    Exit
EndFunc   ;==>Quit

 

Link to comment
Share on other sites

  • Moderators

Bizzaro,

I suggest that JohnOne has already given you a likely answer:

 win 10 is improved at some things as you would expect and memory reading is one of them

Which suggests that you should direct your question towards a Windows forum rather than here.

But as you seem unwilling to answer the question I have now asked you twice, I will assume that you do not wish to do so for the very reasons I asked it - and so this thread will now be closed.

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

  • Moderators

Bizzaro,

You took the time to write me a very uncomplimentary PM, but still did not explain why you need to read the process memory - thanks for confirming my decision.

M23

P.S. If you can convince me that your script does not break the forum rules, I would be ready to reopen the thread - you know where to find me and I do not hold grudges.

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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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