Nine Posted May 10, 2021 Share Posted May 10, 2021 31 minutes ago, Musashi said: The solutions from @JockoDundee, @Nine and @Chimp only work if you specify exactly 8 bits. Not in my case, it is based on StringLen which could be anything. Moreover it allows any bases from 2 to 16. Take a closer look. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
JockoDundee Posted May 10, 2021 Share Posted May 10, 2021 1 hour ago, Chimp said: .. can't look at that absurd array declaration ... Free your mind from conceptual limitations, and all sorts of solutions will appear Gianni 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
major_lee Posted May 10, 2021 Author Share Posted May 10, 2021 Just now, JockoDundee said: Free your mind from conceptual limitations, and all sorts of solutions will appear lol, I do understand that arrays are said to be significantly faster. such as how you did it just in general programming. It's significantly slower, but is doing more too. I think this maybe the most practical approach. Global $iIter = 100000, $sOut, $t = TimerInit() Global Enum $0000, $0001, $0010, $0011, $0100, $0101, $0110, $0111, $1000, $1001 Global Const $1010 = "A", $1011 = "B", $1100 = "C", $1101 = "D", $1110 = "E", $1111 = "F", $cow = "mooo" Global Const $dataStream = "1110111110101101010011010100" For $n = 1 To $iIter Global $sbyte = $dataStream Local $bArray[StringLen ( $sbyte )/4+1] $bArray[0] = (StringLen ( $sbyte )/4) for $z = 1 To $bArray[0] $bArray[$z] = Eval(StringLeft($sbyte, 4)) $sbyte = StringTrimLeft ( $sbyte, 4 ) Next Next $t = TimerDiff($t) For $z = 1 To $bArray[0] ConsoleWrite(" Check: " & $bArray[$z] & " Dec:" &Dec($bArray[$z])& " " &@CRLF ) Next ConsoleWrite($iIter & " Iterations in " & $t / 1000 & " Seconds" & @CRLF & @CRLF) Link to comment Share on other sites More sharing options...
JockoDundee Posted May 10, 2021 Share Posted May 10, 2021 To be clear to those who bemoan the inflexibility of my solution, understand that the gloves came off the moment the OP said: Quote Considering speed as a factor... At that point, a version which provided a 2x speed up over the best effort so far, was entirely on the mark Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
JockoDundee Posted May 10, 2021 Share Posted May 10, 2021 1 hour ago, Musashi said: Here, just for comparison, are the runtime results on my stone-age PC Can you run again? The relative order doesn't match mine: Based on code from: JockoDundee Check: AA 170 100000 Iterations in 0.2239925 Seconds Based on code from: Chimp Check: AA 170 100000 Iterations in 0.2703542 Seconds Based on code from: jhcd Check: 00000000000000AA 170 100000 Iterations in 0.6339325 Seconds Based on code from: nine Check: 000000AA 170 100000 Iterations in 1.1458971 Seconds Based on code from: Musashi Check: 000000AA 170 100000 Iterations in 1.4233144 Seconds Its hard to imagine Eval's being quicker than direct array access. Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Musashi Posted May 10, 2021 Share Posted May 10, 2021 40 minutes ago, Nine said: Not in my case, it is based on StringLen which could be anything. Moreover it allows any bases from 2 to 16. Take a closer look. You are correct, please accept my heartfelt apologies . I used the code that Jocko attached in his runtime tests : Local $sBasedOn="nine", $iIter=100000, $sOut, $t=TimerInit() Local $input="10101010", $bin, $ival, $iLen=8, $base=2 For $n=1 To $iIter $iVal = 0 For $i = 0 to $iLen - 1 $iVal += Dec(StringMid($input, $iLen - $i, 1)) * ($base^$i) Next $sOut=Hex(Int($iVal)) &" "& Int($iVal) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) (there you have to enter 8 bits) Your original code works flawlessly. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
JockoDundee Posted May 10, 2021 Share Posted May 10, 2021 Just now, Musashi said: I used the code that Jocko attached in his runtime tests : I modified his code to give it the best result possible speedwise. No offence was intended. I also mentioned this when I did it. Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Musashi Posted May 10, 2021 Share Posted May 10, 2021 26 minutes ago, JockoDundee said: ... to those who bemoan the inflexibility of my solution ... [...] I modified his code to give it the best result possible speedwise. No offence was intended. I also mentioned this when I did it. In advance : There was never any intention to judge your solution as inflexible or to consider your code customization as an offense. You should know me well enough by now . All solutions fulfill the original requirement of @major_lee ! I just wanted to point out, that some solutions also take variable bit lengths into consideration (no more and no less). 26 minutes ago, JockoDundee said: Can you run again? The relative order doesn't match mine. [...] Its hard to imagine Eval's being quicker than direct array access. I will do that right after dinner. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Nine Posted May 10, 2021 Share Posted May 10, 2021 54 minutes ago, Musashi said: You are correct, please accept my heartfelt apologies No offense taken. And no need to apologize. Just wanted to set things straight Musashi 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
JockoDundee Posted May 10, 2021 Share Posted May 10, 2021 48 minutes ago, Musashi said: There was never any intention to judge your solution as inflexible or to consider your code customization as an offense. You should know me well enough by now . yes of course. If I sounded defensive it’s just because I don’t take lightly modifying others code, but in this case I felt if I didn’t, it would be unfair. Musashi 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Musashi Posted May 10, 2021 Share Posted May 10, 2021 1 hour ago, JockoDundee said: Can you run again? The relative order doesn't match mine. Its hard to imagine Eval's being quicker than direct array access. Here are the results : I used the current code from @Chimp and the one you attached to your post. 3 runs each, with 100,000 and 1,000,000 iterations. Spoiler Based on code from: JockoDundee Check: AA 170 Trial 1 : 100000 Iterations in 0.672229334849915 Seconds Trial 2 : 100000 Iterations in 0.695298712387871 Seconds Trial 3 : 100000 Iterations in 0.654555149199021 Seconds Trial 1 : 1000000 Iterations in 6.23055541014638 Seconds Trial 2 : 1000000 Iterations in 6.19899393218473 Seconds Trial 3 : 1000000 Iterations in 6.30784528241633 Seconds -------------------------------------------------------- Based on code from: Chimp Check: AA 170 Trial 1 : 100000 Iterations in 0.535104653833072 Seconds Trial 2 : 100000 Iterations in 0.531542143656257 Seconds Trial 3 : 100000 Iterations in 0.528054077131515 Seconds Trial 1 : 1000000 Iterations in 5.32384224995548 Seconds Trial 2 : 1000000 Iterations in 5.32383199093629 Seconds Trial 3 : 1000000 Iterations in 5.32107468224003 Seconds JockoDundee 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Musashi Posted May 10, 2021 Share Posted May 10, 2021 (edited) @JockoDundee : From your attached file JD.au3 : [...] $arr[1011]="E" [...] Just a typo : 1110 has to be used for E Edited May 10, 2021 by Musashi JockoDundee 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
JockoDundee Posted May 10, 2021 Share Posted May 10, 2021 3 hours ago, Musashi said: I used the current code from @Chimp and the one you attached to your post. 3 runs each, with 100,000 and 1,000,000 iterations. Thanks! and good catch on the ‘E’. I reran as well, and still showing the opposite by about 10%. Though, looking at my code, I realize there is an implied conversion from string to int that I didn’t see before. are you compiling 64-bit or 32-bit? any other flags? @Chimp, did you see any performance difference between the two on your machine? btw, another version I tried initially was with 16 functions and Execute, though it was pretty slow. Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
major_lee Posted May 11, 2021 Author Share Posted May 11, 2021 (edited) Here are my result with three same baseline test. Quote Based on code from: nine Check: 000000AA 170 1000000 Iterations in 18.0934664 Seconds Based on code from: nine Check: 000000AA 170 1000000 Iterations in 17.3470087 Seconds Based on code from: nine Check: 000000AA 170 1000000 Iterations in 17.2345381 Seconds Local $sBasedOn="nine", $iIter=1000000, $sOut, $t=TimerInit() Local $input="10101010", $bin, $ival, $iLen=8, $base=2 For $n=1 To $iIter $iVal = 0 For $i = 0 to $iLen - 1 $iVal += Dec(StringMid($input, $iLen - $i, 1)) * ($base^$i) Next $sOut=Hex(Int($iVal)) &" "& Int($iVal) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) Quote Based on code from: jhcd Check: 00000000000000AA 170 1000000 Iterations in 12.155069 Seconds Based on code from: jhcd Check: 00000000000000AA 170 1000000 Iterations in 11.0118714 Seconds Based on code from: jhcd Check: 00000000000000AA 170 1000000 Iterations in 9.2977334 Seconds Local $sBasedOn="jhcd", $iIter=1000000, $sOut, $t=TimerInit() Local $input="10101010", $bin, $aDll=DllOpen("msvcrt.dll") For $n=1 To $iIter $bin=DllCall($aDll, "int64:cdecl", "_wcstoi64", "wstr", $input, "ptr*", 0, "int", 2)[0] $sOut=Hex($bin) &" "& $bin Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) Quote Based on code from: Musashi Check: 000000AA 170 1000000 Iterations in 21.2172401 Seconds Based on code from: Musashi Check: 000000AA 170 1000000 Iterations in 21.3587079 Seconds Based on code from: Musashi Check: 000000AA 170 1000000 Iterations in 20.9960947 Seconds Local $sBasedOn="Musashi", $iIter=1000000, $sOut, $t=TimerInit() Local $input="10101010", $aArr, $dec For $n=1 To $iIter $aArr = StringSplit($input, "", 2) $dec = 0 For $i = UBound($aArr) - 1 To 0 Step -1 If $aArr[$i] = "1" Then $dec = BitXOR($dec, BitShift(1, -(UBound($aArr) - 1 - $i))) $sOut=Hex($dec) &" "& $dec EndIf Next Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) Quote Based on code from: JockoDundee Check: AA 170 1000000 Iterations in 3.4197433 Seconds Based on code from: JockoDundee Check: AA 170 1000000 Iterations in 3.3934325 Seconds Based on code from: JockoDundee Check: AA 170 1000000 Iterations in 3.4096929 Seconds Local $sBasedOn="JockoDundee", $iIter=1000000, $sOut, $t=TimerInit() Local $sbyte="10101010", $arr[1112] $arr[0]="0" $arr[1]="1" $arr[10]="2" $arr[11]="3" $arr[100]="4" $arr[101]="5" $arr[110]="6" $arr[111]="7" $arr[1000]="8" $arr[1001]="9" $arr[1010]="A" $arr[1011]="B" $arr[1100]="C" $arr[1101]="D" $arr[1011]="E" $arr[1111]="F" For $n=1 To $iIter $sOut=$arr[StringLeft($sByte,4)] & $arr[StringRight($sByte,4)] $sOut=$sOut &" "& Dec($sOut) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) Quote Based on code from: Chimp Check: AA 170 1000000 Iterations in 3.9945812 Seconds Based on code from: Chimp Check: AA 170 1000000 Iterations in 4.080412 Seconds Based on code from: Chimp Check: AA 170 1000000 Iterations in 4.0526451 Seconds Global $sBasedOn = "Chimp", $iIter = 1000000, $sOut, $t = TimerInit() Global $sbyte = "10101010" Global Enum $0000, $0001, $0010, $0011, $0100, $0101, $0110, $0111, $1000, $1001 Global $1010 = "A", $1011 = "B", $1100 = "C", $1101 = "D", $1110 = "E", $1111 = "F" For $n = 1 To $iIter $sOut = Eval(StringLeft($sbyte, 4)) & Eval(StringRight($sbyte, 4)) $sOut = $sOut & " " & Dec($sOut) Next $t = TimerDiff($t) ConsoleWrite("Based on code from: " & $sBasedOn & @CRLF & " Check: " & $sOut & " " & @CRLF & " " & $iIter & " Iterations in " & $t / 1000 & " Seconds" & @CRLF & @CRLF) Quote Based on code from: Chimp with major_lee edit Check: AA 170 1000000 Iterations in 11.2108708 Seconds Based on code from: Chimp with major_lee edit Check: AA 170 1000000 Iterations in 11.2885781 Seconds Based on code from: Chimp with major_lee edit Check: AA 170 1000000 Iterations in 11.0158957 Seconds Global $sBasedOn="Chimp with major_lee edit", $iIter = 1000000, $sOut, $t = TimerInit() Global Enum $0000, $0001, $0010, $0011, $0100, $0101, $0110, $0111, $1000, $1001 Global Const $1010 = "A", $1011 = "B", $1100 = "C", $1101 = "D", $1110 = "E", $1111 = "F" Global $dataStream = "10101010" For $n = 1 To $iIter $sbyte = $dataStream $sOut = Null Local $bArray[StringLen ( $sbyte )/4+1] $bArray[0] = (StringLen ( $sbyte )/4) for $z = 1 To $bArray[0] $bArray[$z] = Eval(StringLeft($sbyte, 4)) $sbyte = StringTrimLeft ( $sbyte, 4 ) $sOut=$sOut&$bArray[$z] Next $sOut=$sOut &" "& Dec($sOut) Next $t = TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) Edited May 11, 2021 by major_lee benchmark for chimp typo, and jhcd $iIter Link to comment Share on other sites More sharing options...
argumentum Posted May 11, 2021 Share Posted May 11, 2021 (edited) I wanna play too: Tester() Func Tester() Local $t, $sResult, $sbyteOriginal="10101010" Local $o = ObjCreate("Scripting.Dictionary") $o.Add("0000", "0") $o.Add("0001", "1") $o.Add("0010", "2") $o.Add("0011", "3") $o.Add("0100", "4") $o.Add("0101", "5") $o.Add("0110", "6") $o.Add("0111", "7") $o.Add("1000", "8") $o.Add("1001", "9") $o.Add("1010", "A") $o.Add("1011", "B") $o.Add("1100", "C") $o.Add("1101", "D") $o.Add("1110", "E") $o.Add("1111", "F") $t = TimerInit() For $n = 1 To 1000 ; >>> 9.7685 - $sResult: AA $sResult = "" $sbyte = $sbyteOriginal Do $sResult &= $o.Item(StringLeft($sbyte, 4)) $sbyte = StringTrimLeft($sbyte, 4) Until $sbyte = "" Next ConsoleWrite(">>> " &TimerDiff($t)& " - $sResult: " & $sResult & @CRLF) EndFunc And, I'd win 1st price for slowest original idea Edit: since I don't wanna lose to myself, here is a yet slower ones: Spoiler expandcollapse popupTester() Func Tester() Local $t, $sResult, $sbyteOriginal="10101010" $t = TimerInit() For $n = 1 To 1000 ; >>> 12.0355 - $sResult: AA $sResult = "" $sbyte = $sbyteOriginal Do $sResult &= StrBin2Hex(StringLeft($sbyte, 4)) $sbyte = StringTrimLeft($sbyte, 4) Until $sbyte = "" Next ConsoleWrite(">>> " &TimerDiff($t)& " - $sResult: " & $sResult & @CRLF) EndFunc Func StrBin2Hex($sBin) Switch $sBin Case "0000" Return "0" Case "0001" Return "1" Case "0010" Return "2" Case "0011" Return "3" Case "0100" Return "4" Case "0101" Return "5" Case "0110" Return "6" Case "0111" Return "7" Case "1000" Return "8" Case "1001" Return "9" Case "1010" Return "A" Case "1011" Return "B" Case "1100" Return "C" Case "1101" Return "D" Case "1110" Return "E" Case "1111" Return "F" EndSwitch EndFunc Tester() Func Tester() Local $t, $sResult, $sbyteOriginal="10101010" Local Const $tagSBINTHING = "struct;CHAR 0000;CHAR 0001;CHAR 0010;CHAR 0011;CHAR 0100;CHAR 0101;CHAR 0110;CHAR 0111;" & _ "CHAR 1000;CHAR 1001;CHAR 1010;CHAR 1011;CHAR 1100;CHAR 1101;CHAR 1110;CHAR 1111;endstruct" Local $tSBINTHING = DllStructCreate($tagSBINTHING) ; ...GETTING FANCY HERE ;) DllStructSetData($tSBINTHING, "0000", "0") DllStructSetData($tSBINTHING, "0001", "1") DllStructSetData($tSBINTHING, "0010", "2") DllStructSetData($tSBINTHING, "0011", "3") DllStructSetData($tSBINTHING, "0100", "4") DllStructSetData($tSBINTHING, "0101", "5") DllStructSetData($tSBINTHING, "0110", "6") DllStructSetData($tSBINTHING, "0111", "7") DllStructSetData($tSBINTHING, "1000", "8") DllStructSetData($tSBINTHING, "1001", "9") DllStructSetData($tSBINTHING, "1010", "A") DllStructSetData($tSBINTHING, "1011", "B") DllStructSetData($tSBINTHING, "1100", "C") DllStructSetData($tSBINTHING, "1101", "D") DllStructSetData($tSBINTHING, "1110", "E") DllStructSetData($tSBINTHING, "1111", "F") $t = TimerInit() For $n = 1 To 1000 ; >>> 10.1052 - $sResult: AA $sResult = "" $sbyte = $sbyteOriginal Do $sResult &= DllStructGetData($tSBINTHING, StringLeft($sbyte, 4)) $sbyte = StringTrimLeft($sbyte, 4) Until $sbyte = "" Next ConsoleWrite(">>> " &TimerDiff($t)& " - $sResult: " & $sResult & @CRLF) EndFunc Edited May 11, 2021 by argumentum am a sore loser/winner major_lee 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Musashi Posted May 11, 2021 Share Posted May 11, 2021 8 hours ago, JockoDundee said: ... are you compiling 64-bit or 32-bit? any other flags? All flags in my AutoIt/SciTE version (3.3.14.0) are on default (e.g. x64=No). If I set the directive #AutoIt3Wrapper_UseX64 = Y , then your variant is faster than Chimp's (as you stated) . Based on code from: Chimp-> with #AutoIt3Wrapper_UseX64 = Y (Default=N)==> Trial 1 : 1000000 Iterations in 4.46783944157985 Seconds ==> Trial 2 : 1000000 Iterations in 4.4102539416485 Seconds ==> Trial 3 : 1000000 Iterations in 4.39570894432897 Seconds Based on code from: JockoDundee-> with #AutoIt3Wrapper_UseX64 = Y (Default=N)==> Trial 1 : 1000000 Iterations in 3.6696164912397 Seconds ==> Trial 2 : 1000000 Iterations in 3.7065374362568 Seconds ==> Trial 3 : 1000000 Iterations in 3.6125747123171 Seconds 4 hours ago, argumentum said: I wanna play too: Funny, I also tried it via a "Scripting.Dictionary Object" but it is, as you wrote, slow . Spoiler Local $sBasedOn = "Musashi : Dictionary", $iIter=1000000, $sOut, $t=TimerInit(), $oDictionary Local $sbyte = "10101010" $oDictionary = ObjCreate("Scripting.Dictionary") If @error Then Exit MsgBox(0, 'Message : ', 'Error creating the dictionary object') Else $oDictionary.Add ("0000", "0") $oDictionary.Add ("0001", "1") $oDictionary.Add ("0010", "2") $oDictionary.Add ("0011", "3") $oDictionary.Add ("0100", "4") $oDictionary.Add ("0101", "5") $oDictionary.Add ("0110", "6") $oDictionary.Add ("0111", "7") $oDictionary.Add ("1000", "8") $oDictionary.Add ("1001", "9") $oDictionary.Add ("1010", "A") $oDictionary.Add ("1011", "B") $oDictionary.Add ("1100", "C") $oDictionary.Add ("1101", "D") $oDictionary.Add ("1110", "E") $oDictionary.Add ("1111", "F") EndIf For $n = 1 To $iIter $sOut = $oDictionary.Item(StringLeft($sByte,4)) & $oDictionary.Item(StringRight($sByte,4)) $sOut = $sOut & " " & Dec($sOut) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" & @CRLF & @CRLF) "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Gianni Posted May 11, 2021 Share Posted May 11, 2021 13 hours ago, JockoDundee said: @Chimp, did you see any performance difference between the two on your machine? ... your is a bit faster: Based on code from: Chimp Check: AA 170 100000 Iterations in 0.5807074 Seconds Based on code from: JockoDundee Check: AA 170 100000 Iterations in 0.5009863 Seconds Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
major_lee Posted May 11, 2021 Author Share Posted May 11, 2021 This is cool, cause I'm learning a lot, all the different ways it can be done. I've never even considered using COM objects. Quote Based on code from: argumentum Check: AA 170 1000000 Iterations in 10.8612472 Seconds Based on code from: argumentum Check: AA 170 1000000 Iterations in 10.9447503 Seconds Based on code from: argumentum Check: AA 170 1000000 Iterations in 10.5175166 Seconds Local $sBasedOn="argumentum", $iIter=1000000, $t=TimerInit() Local $sResult, $sbyteOriginal="10101010", $dec Local $o = ObjCreate("Scripting.Dictionary") $o.Add("0000", "0") $o.Add("0001", "1") $o.Add("0010", "2") $o.Add("0011", "3") $o.Add("0100", "4") $o.Add("0101", "5") $o.Add("0110", "6") $o.Add("0111", "7") $o.Add("1000", "8") $o.Add("1001", "9") $o.Add("1010", "A") $o.Add("1011", "B") $o.Add("1100", "C") $o.Add("1101", "D") $o.Add("1110", "E") $o.Add("1111", "F") For $n=1 To $iIter $sResult = "" $sbyte = $sbyteOriginal Do $sResult &= $o.Item(StringLeft($sbyte, 4)) $sbyte = StringTrimLeft($sbyte, 4) Until $sbyte = "" $sOut = $sResult &" "& Dec($sResult) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) argumentum 1 Link to comment Share on other sites More sharing options...
major_lee Posted May 11, 2021 Author Share Posted May 11, 2021 I think its only fair to extend the code to handle more then the limited bytes as originally assumed. Quote Based on code from: JockoDundee with major_lee edit Check: AA 170 1000000 Iterations in 10.7270697 Seconds Based on code from: JockoDundee with major_lee edit Check: AA 170 1000000 Iterations in 10.7771624 Seconds Based on code from: JockoDundee with major_lee edit Check: AA 170 1000000 Iterations in 10.7246844 Seconds expandcollapse popupLocal $sBasedOn="JockoDundee with major_lee edit", $iIter=1000000, $sOut, $t=TimerInit() Local $dataStream="10101010", $arr[1112] $arr[0]="0" $arr[1]="1" $arr[10]="2" $arr[11]="3" $arr[100]="4" $arr[101]="5" $arr[110]="6" $arr[111]="7" $arr[1000]="8" $arr[1001]="9" $arr[1010]="A" $arr[1011]="B" $arr[1100]="C" $arr[1101]="D" $arr[1011]="E" $arr[1111]="F" For $n=1 To $iIter $sbyte = $dataStream $sOut = Null Local $bArray[StringLen ( $sbyte )/4+1] $bArray[0] = (StringLen ( $sbyte )/4) for $z = 1 To $bArray[0] $bArray[$z] = $arr[StringLeft($sbyte, 4)] $sbyte = StringTrimLeft ( $sbyte, 4 ) $sOut=$sOut&$bArray[$z] Next $sOut=$sOut &" "& Dec($sOut) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) Link to comment Share on other sites More sharing options...
JockoDundee Posted May 11, 2021 Share Posted May 11, 2021 6 hours ago, Musashi said: If I set the directive #AutoIt3Wrapper_UseX64 = Y Anybody have any theories why 64bit vs 32bit would make such a big difference? Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
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