DrAhmed Posted April 29, 2016 Posted April 29, 2016 (edited) Hey I've these two functions to do a base64 conversation , Is there any way to compare the exact speed of both of them ? expandcollapse popupFunc _Base64Encode($input) $input = Binary($input) Local $struct = DllStructCreate("byte[" & BinaryLen($input) & "]") DllStructSetData($struct, 1, $input) Local $strc = DllStructCreate("int") Local $a_Call = DllCall("Crypt32.dll", "int", "CryptBinaryToString", _ "ptr", DllStructGetPtr($struct), _ "int", DllStructGetSize($struct), _ "int", 1, _ "ptr", 0, _ "ptr", DllStructGetPtr($strc)) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") ; error calculating the length of the buffer needed EndIf Local $a = DllStructCreate("char[" & DllStructGetData($strc, 1) & "]") $a_Call = DllCall("Crypt32.dll", "int", "CryptBinaryToString", _ "ptr", DllStructGetPtr($struct), _ "int", DllStructGetSize($struct), _ "int", 1, _ "ptr", DllStructGetPtr($a), _ "ptr", DllStructGetPtr($strc)) If @error Or Not $a_Call[0] Then Return SetError(2, 0, ""); error encoding EndIf Return DllStructGetData($a, 1) EndFunc ;==>_Base64Encode Func _Base64Encode($sData) Local $oXml = ObjCreate("Msxml2.DOMDocument") If Not IsObj($oXml) Then SetError(1, 1, 0) EndIf Local $oElement = $oXml.createElement("b64") If Not IsObj($oElement) Then SetError(2, 2, 0) EndIf $oElement.dataType = "bin.base64" $oElement.nodeTypedValue = Binary($sData) Local $sReturn = $oElement.Text If StringLen($sReturn) = 0 Then SetError(3, 3, 0) EndIf Return $sReturn EndFunc ;==>_Base64Encode Edited April 29, 2016 by DrAhmed
Moderators JLogan3o13 Posted April 29, 2016 Moderators Posted April 29, 2016 @DrAhmed look at TimerInit() and TimerDiff() in the help file. You should be able to add that in to each of your functions to get an idea of the time they take. DrAhmed 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
DrAhmed Posted April 29, 2016 Author Posted April 29, 2016 28 minutes ago, JLogan3o13 said: @DrAhmed look at TimerInit() and TimerDiff() in the help file. You should be able to add that in to each of your functions to get an idea of the time they take. Could you give me an example please ?
Moderators JLogan3o13 Posted April 29, 2016 Moderators Posted April 29, 2016 @DrAhmed There is an awesome example...in the help file for TimerDiff: Add a TimerInit() to the top of your function, and then a TimerDiff right before your Return statement, done. DrAhmed 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Danyfirex Posted April 29, 2016 Posted April 29, 2016 Hello. #include <String.au3> Local $sString = _StringRepeat("Hello Word", 1000) Local $hTimer = TimerInit() For $i = 1 To 100 _Base64Encode($sString) Next Local $iDiff = TimerDiff($hTimer) ConsoleWrite("_Base64Encode time elapsed: " & $iDiff & @CRLF) $hTimer = TimerInit() For $i = 1 To 100 _Base64EncodeMsxml($sString) Next $iDiff = TimerDiff($hTimer) ConsoleWrite("_Base64EncodeMsxml time elapsed: " & $iDiff & @CRLF) Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Moderators JLogan3o13 Posted April 29, 2016 Moderators Posted April 29, 2016 Not exactly the "teach a man to fish" method, @Danyfirex Danyfirex 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Danyfirex Posted April 29, 2016 Posted April 29, 2016 15 minutes ago, JLogan3o13 said: Not exactly the "teach a man to fish" method, @Danyfirex mine is more like let them choose if want to learn or want just the fish till teacher dies. lol Saludos DrAhmed 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now