Popular Post seangriffin Posted Monday at 10:17 AM Popular Post Posted Monday at 10:17 AM (edited) I created this UDF for JSON using JSON-C because I needed high performance parsing of JSON data in my script. I needed to query large data arrays of several thousand entries and other UDFs were taking many seconds to do so. With this UDF a query of 5,000 array entries takes me about 600ms (see Example2.au3). This UDF executes JSON functions through a JSON-C DLL to achieve better performance. The JSON-C project is https://github.com/json-c/json-c. To download this UDF please visit https://github.com/seanhaydongriffin/JsonC-UDF. Two examples are provided (Example1.au3 and Example2.au3) that demonstrate all the functions. Edited Monday at 10:19 AM by seangriffin AspirinJunkie, ioa747, Musashi and 3 others 6 Cheers, Sean. See my other UDFs: Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax See my other Tools: Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia
argumentum Posted Monday at 02:11 PM Posted Monday at 02:11 PM String: { "name": "Alice", "age": 30, "height": 175.80000000000001, <--- Alice got unnoticeably taller but then again Height type: double, value (using GetDouble): 175.8 . Why the extra ...001 in the string format ? Also a request: a prettified output if the code permits. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
AspirinJunkie Posted Tuesday at 08:03 PM Posted Tuesday at 08:03 PM (edited) Certainly better performance for complex JSON documents and therefore great to have another tool in the toolbox of JSON problem solvers. 👍 I took the case of the individual array extraction from the meta.json to carry out the performance comparison mentioned above (test script in the appendix). This was my result: speed comparison.zip Edited Wednesday at 06:30 AM by AspirinJunkie improved RegEx-Pattern and force 64 bit mode
TheXman Posted Tuesday at 08:33 PM Posted Tuesday at 08:33 PM (edited) Here are the results with jq added to the mix. This was run on a 10 year old Dell XPS 8700 running Windows 7 64bit. That explains the slower speeds overall. speed comparison.zip Edited Wednesday at 02:32 PM by TheXman Updated the results using Aprinjunkie's updated script argumentum, AspirinJunkie, mLipok and 1 other 4 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
seangriffin Posted Wednesday at 01:18 AM Author Posted Wednesday at 01:18 AM I am very excited about the jq UDF now. It looks so fast. Thanks @TheXman. I'll definitely check it out. TheXman 1 Cheers, Sean. See my other UDFs: Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax See my other Tools: Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia
TheXman Posted Wednesday at 01:49 AM Posted Wednesday at 01:49 AM jq is very fast and it is very powerful too. It can do much more than parse JSON. jq is a JSON processor. Meaning, a lot of the post-processing of JSON data that you would normally do using AutoIt functions can be accomplished using jq, in a single jq filter, and be done much quicker too. The jq UDF has a few examples included in the zip file and jqPlayground has many more (20+) example jq filters to help you get started learning what jq can do. jqPlayground can be very helpful as a learning tool because it is interactive and allows you to save and restore sessions. mLipok 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
argumentum Posted Wednesday at 02:22 AM Posted Wednesday at 02:22 AM (edited) ..I posted these many pics because I couldn't believe that JSON-C was slower than others. Spoiler Edit: oops, did run in 32bit hence the JSON-C did not do anything. It does look faster doing nothing Edited Wednesday at 06:09 AM by argumentum oops Danp2 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
AspirinJunkie Posted Wednesday at 04:41 AM Posted Wednesday at 04:41 AM (edited) Have you changed anything in the script? Maybe so that $sScript is suddenly empty or something? Have you checked the result to see if this is really what the code produces? (an _ArrayDisplay() on $aActions for example) Or may I guess?: You are running your script as 32-bit instead of 64-bit? Then the results would be plausible, as nothing is being processed (you should be able to tell from the result). The results don't look very plausible (and I can't reproduce them either). The For-Loop alone to get the AutoIt array from the JsonC results is just 40% faster than the StringRegExp solution in my tests - there is not even a single Json-C code involved. This clashes with your results that the whole call should be ~230x faster than the StringRegExp solution. There was a small indexing error in the script, which I fixed. At the same time, I also added jq to my results above. Edited Wednesday at 05:27 AM by AspirinJunkie
argumentum Posted Wednesday at 05:41 AM Posted Wednesday at 05:41 AM (edited) 1 hour ago, AspirinJunkie said: Or may I guess?: You are running your script as 32-bit instead of 64-bit? ...had no clue that had to be x64, or rather that I'd have to run the script x64 instead of click-click do add something along the lines of: #AutoIt3Wrapper_UseX64=y If Not @AutoItX64 Then Exit MsgBox(0, @ScriptName, "Please run as x64", 10) for those "click-click-ers" like myself Edited Wednesday at 06:19 AM by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
TheXman Posted Wednesday at 11:32 AM Posted Wednesday at 11:32 AM (edited) 7 hours ago, AspirinJunkie said: I also added jq to my results above. Your updated zip file includes jq code in the SpeedComparison.au3 script, but it does not include the required jq.udf and jq-win64.exe files. Edited Wednesday at 11:57 AM by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
AspirinJunkie Posted Wednesday at 12:37 PM Posted Wednesday at 12:37 PM Remarkably true - I have updated it.
water Posted Wednesday at 02:13 PM Posted Wednesday at 02:13 PM I added your UDF to the wiki 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
argumentum Posted Wednesday at 05:04 PM Posted Wednesday at 05:04 PM (edited) ;~ _ArrayDisplay($a_Results, "Results over " & $i_Runs & " loops", "", 16 + 64, Default, "name|time[ms]|factor|Std. Dev|Std. Err.|min|max|range") ;~ #include <SQLite.au3> ConsoleWriteResult() Func ConsoleWriteResult() ConsoleWrite(@CRLF & RegRead("HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString") & _ " | Runs: " & $i_Runs & " | WinVer: " & FileGetVersion("WinVer.exe") & @CRLF & @CRLF) Local $aHead = StringSplit("name|time[ms]|factor|Std. Dev|Std. Err.|min|max|range", "|", 2) ; header from _ArrayDisplay() ReDim $a_Results[UBound($a_Results) + 2][UBound($a_Results, 2)] For $n = UBound($a_Results) - 3 To 0 Step -1 For $m = 0 To UBound($a_Results, 2) - 1 $a_Results[$n + 2][$m] = $a_Results[$n][$m] Next Next For $m = 0 To UBound($a_Results, 2) - 1 $a_Results[0][$m] = $aHead[$m] $a_Results[1][$m] = "------" Next _SQLite_Display2DResult($a_Results, 0, False, "|", "|" & @CRLF) EndFunc ;==>ConsoleWriteResult Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz | Runs: 100 | WinVer: 10.0.22621.1 name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 2.807 | 1 | 0.225 | 0.022 | 2.638 | 3.65 | 1.012 | JsonC-UDF | 90.724 | 32.32 | 2.622 | 0.262 | 87.264 | 104.752 | 17.487 | jq UDF | 163.349 | 58.19 | 8.394 | 0.839 | 135.862 | 182.644 | 46.783 | pure AutoIt JSON-UDF | 171.625 | 61.14 | 3.261 | 0.326 | 164.824 | 184.02 | 19.196 | JSMN-based JSON-UDF | 190.401 | 67.83 | 3.561 | 0.356 | 184.436 | 203.804 | 19.369 | Since sharing pictures ( due to forum user max file(s) space ) gets expensive, sharing the data as text is better for us. This is running @TheXman's test file. Am still wondering on why Win7 is so different from Win11/10 results. Or is it HDD vs NVMe. Or ... 🤔 Edit: another PC: 12th Gen Intel(R) Core(TM) i9-12900H | Runs: 100 | WinVer: 24H2 (26100) name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 1.691 | 1 | 0.351 | 0.035 | 1.304 | 3.167 | 1.863 | jq UDF | 32.933 | 19.48 | 2.929 | 0.293 | 29.308 | 43.169 | 13.861 | JsonC-UDF | 51.086 | 30.21 | 3.205 | 0.321 | 45.625 | 63.46 | 17.835 | pure AutoIt JSON-UDF | 97.916 | 57.9 | 5.685 | 0.569 | 86.362 | 113.467 | 27.105 | JSMN-based JSON-UDF | 108.248 | 64.01 | 5.512 | 0.551 | 99.029 | 130.864 | 31.835 | Intel(R) Pentium(R) Silver N6000 @ 1.10GHz | Runs: 100 | WinVer: 10.0.14393.0 name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 3.255 | 1 | 0.198 | 0.02 | 3.076 | 4.043 | 0.967 | jq UDF | 50.396 | 15.48 | 1.756 | 0.176 | 47.438 | 59.49 | 12.052 | JsonC-UDF | 112.045 | 34.42 | 8.776 | 0.878 | 106.967 | 181.859 | 74.892 | pure AutoIt JSON-UDF | 199.033 | 61.15 | 3.439 | 0.344 | 194.587 | 211.019 | 16.432 | JSMN-based JSON-UDF | 222.099 | 68.23 | 3.823 | 0.382 | 216.491 | 239.937 | 23.446 | Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz | Runs: 100 | WinVer: 10.0.26100.1 name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 3.15 | 1 | 0.15 | 0.015 | 3.002 | 3.628 | 0.626 | jq UDF | 65.22 | 20.7 | 1.928 | 0.193 | 63.274 | 74.064 | 10.791 | JsonC-UDF | 110.34 | 35.03 | 3.961 | 0.396 | 106.711 | 137.913 | 31.202 | pure AutoIt JSON-UDF | 209.692 | 66.57 | 4.29 | 0.429 | 203.294 | 225.663 | 22.368 | JSMN-based JSON-UDF | 226.071 | 71.77 | 4.477 | 0.448 | 218.189 | 247.016 | 28.827 | Edited Wednesday at 07:41 PM by argumentum more Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
TheXman Posted Wednesday at 05:38 PM Posted Wednesday at 05:38 PM Are your tests being run on virtual machines or physical machines? argumentum 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
argumentum Posted Wednesday at 05:53 PM Posted Wednesday at 05:53 PM (edited) In my "coding life", I rarely use JSON and when I do is infrequent and a small string, so speed/efficiency is not a big deal for me in my cases. Having a prettified output is quite important to me because I use it a lot to discern how to go about a JSON when I have to deal with one. .,.back to topic. The "N6000" is a Server 2016 VM but the others are hardware. In my trend of thought, build in ( all AutoIt ) is preferable than having an external file but if is an external file a DLL would be a faster data exchange, but that EXE is kicking other methods ass "from here to China town" as they say. I just don't understand why/how. Also don't get the inconsistencies between one PC and another. And that is my "hmm" moment 🤔 Edited Wednesday at 05:58 PM by argumentum English Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted Wednesday at 06:10 PM Posted Wednesday at 06:10 PM (edited) CPU architecture changes and that I think is the difference. Spoiler ×Intel Pentium Silver N6000 @ 1.10GHz ×Intel Core i7-12700H ×Intel Core i9-9900K @ 3.60GHz ×Intel Core i5-3470 @ 3.20GHz Socket Type FCBGA1338 FCBGA1744 FCLGA1151-2 LGA1155 CPU Class Mobile/Embedded Laptop Desktop Desktop Clockspeed 1.1 GHz 2.3 GHz 3.6 GHz 3.2 GHz Turbo Speed Up to 3.0 GHz Up to 4.7 GHz Up to 5.0 GHz Up to 3.6 GHz # of Physical Cores 4 (Threads: 4) 14 (Threads: 20) 8 (Threads: 16) 4 (Threads: 4) Cache L1: 256KB, L2: 1.5MB, L3: 4MB L1: 1,248KB, L2: 11.5MB, L3: 24MB L1: 512KB, L2: 2.0MB, L3: 16MB L1: 256KB, L2: 1.0MB, L3: 6MB TDP 6W 45W 95W 77W Other Intel UHD Graphics Intel Iris Xe Graphics Intel UHD Graphics 630 First Seen on Chart Q1 2021 Q1 2022 Q4 2018 Q3 2012 # of Samples 183 7169 14718 10193 Single Thread Rating(% diff. to max in group) 1395(-60.8%) 3555(0.0%) 2922(-17.8%) 1937(-45.5%) CPU Mark(% diff. to max in group) 3010(-88.4%) 25847(0.0%) 18190(-29.6%) 4671(-81.9%) 1 - Last seen price from our affiliates NewEgg.com & Amazon.com. So I guess that is the answer to my question. Nope, not it. Edit2: playing around with the script: Spoiler expandcollapse popup#AutoIt3Wrapper_UseX64=y ; y If Not @AutoItX64 Then Exit MsgBox(0, @ScriptName, "Please run as x64", 10) #include <Debug.au3> #include <SQLite.au3> #include <Array.au3> #include "JsonC.au3" #include "JSON.au3" #include "Json-Ward.au3" #include "jq.au3" Global $what = "actions" ; 5061 entries Global $whatCount = 5061 ;~ Global $what = "copilot" ; 15 entries ;~ Global $whatCount = 15 _JsonC_Startup("json-c.dll") Global Const $i_Runs = 100 Global $f_DecimalPlaces = 3 Global $iT, $a_Results[0][8] ;~ Global $hTimer = TimerInit() Global Const $sString = FileRead("meta.json") ;~ ConsoleWrite(TimerDiff($hTimer) & @CRLF) ; 0.8322 ms. ;~ Exit ;~ Exit _DebugArrayDisplay(countEntries(), "countEntries - " & @extended & " ms.") Func countEntries() Local $hTimer = TimerInit() Local $sRegEx = "(?m)(?:\""|\')(?<key>[\w\d]+)(?:\""|\')(?:\:\s*)(?:\""|\')?(?<value>[\w\s-]*)(?:\""|\')?" Local $aArray = StringRegExp($sString, $sRegEx, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aTemp, $aRE, $aActions, $aTotals[UBound($aArray)][2] For $i = 0 To UBound($aArray) - 1 $aTemp = $aArray[$i] $aTotals[$i][0] = $aTemp[1] $aRE = StringRegExp($sString, '(?sm)^\s*"' & $aTotals[$i][0] & '"\s*:([^\]]+)', 1) $aActions = StringRegExp($aRE[0], '"([^"]+)"', 3) $aTotals[$i][1] = UBound($aActions) Next Return SetError(0, TimerDiff($hTimer), $aTotals) EndFunc ;==>countEntries ; the first measurement Global $Sum = 0, $QuSum = 0, $min = 1e15, $max = 0, $iT ReDim $a_Results[UBound($a_Results) + 1][8] $a_Results[UBound($a_Results) - 1][0] = "JsonC-UDF" For $i = 1 To $i_Runs $iT = TimerInit() ; code start $Json = _JsonC_TokenerParse($sString) $aActions = _JsonC_ObjectArrayGetObjects(_JsonC_ObjectObjectGet($Json, $what)) For $j = 0 To UBound($aActions) - 1 $aActions[$j] = _JsonC_ObjectGetValue($aActions[$j]) Next ; code end $iT = TimerDiff($iT) $Sum += $iT $QuSum += $iT * $iT If $iT < $min Then $min = $iT If $iT > $max Then $max = $iT Next $f_StdDev = Sqrt(($QuSum - ($Sum ^ 2) / $i_Runs) / ($i_Runs - 1)) $f_StdErr = $f_StdDev / Sqrt($i_Runs) $a_Results[UBound($a_Results) - 1][1] = $Sum / $i_Runs $a_Results[UBound($a_Results) - 1][3] = $f_StdDev $a_Results[UBound($a_Results) - 1][4] = $f_StdErr $a_Results[UBound($a_Results) - 1][5] = $min $a_Results[UBound($a_Results) - 1][6] = $max $a_Results[UBound($a_Results) - 1][7] = $max - $min ; Ward`s JSMN-based JSON-UDF Global $Sum = 0, $QuSum = 0, $min = 1e15, $max = 0, $iT ReDim $a_Results[UBound($a_Results) + 1][8] $a_Results[UBound($a_Results) - 1][0] = "JSMN-based JSON-UDF" For $i = 1 To $i_Runs $iT = TimerInit() ; code start $oJSON = Json_Decode($sString) $aActions = Json_ObjGet($oJSON, $what) ; code end $iT = TimerDiff($iT) $Sum += $iT $QuSum += $iT * $iT If $iT < $min Then $min = $iT If $iT > $max Then $max = $iT Next $f_StdDev = Sqrt(($QuSum - ($Sum ^ 2) / $i_Runs) / ($i_Runs - 1)) $f_StdErr = $f_StdDev / Sqrt($i_Runs) $a_Results[UBound($a_Results) - 1][1] = $Sum / $i_Runs $a_Results[UBound($a_Results) - 1][3] = $f_StdDev $a_Results[UBound($a_Results) - 1][4] = $f_StdErr $a_Results[UBound($a_Results) - 1][5] = $min $a_Results[UBound($a_Results) - 1][6] = $max $a_Results[UBound($a_Results) - 1][7] = $max - $min ; pure AutoIt JSON-UDF Global $Sum = 0, $QuSum = 0, $min = 1e15, $max = 0, $iT ReDim $a_Results[UBound($a_Results) + 1][8] $a_Results[UBound($a_Results) - 1][0] = "pure AutoIt JSON-UDF" For $i = 1 To $i_Runs $iT = TimerInit() ; code start $vJSON = _JSON_Parse($sString) $aActions = _JSON_Get($vJSON, $what) ; code end $iT = TimerDiff($iT) $Sum += $iT $QuSum += $iT * $iT If $iT < $min Then $min = $iT If $iT > $max Then $max = $iT Next $f_StdDev = Sqrt(($QuSum - ($Sum ^ 2) / $i_Runs) / ($i_Runs - 1)) $f_StdErr = $f_StdDev / Sqrt($i_Runs) $a_Results[UBound($a_Results) - 1][1] = $Sum / $i_Runs $a_Results[UBound($a_Results) - 1][3] = $f_StdDev $a_Results[UBound($a_Results) - 1][4] = $f_StdErr $a_Results[UBound($a_Results) - 1][5] = $min $a_Results[UBound($a_Results) - 1][6] = $max $a_Results[UBound($a_Results) - 1][7] = $max - $min ; jq UDF Global $Sum = 0, $QuSum = 0, $min = 1e15, $max = 0, $iT ReDim $a_Results[UBound($a_Results) + 1][8] $a_Results[UBound($a_Results) - 1][0] = "jq UDF" _jqPath(Default) If @error Then Exit MsgBox($MB_ICONERROR, "_jqInit Error", "@error = " & @error) For $i = 1 To $i_Runs $iT = TimerInit() ; code start $sActions = _jqExec($sString, "." & $what & "[]") If @error Then Exit MsgBox($MB_ICONERROR, "_jqExec Error", "@error = " & @error) $aActions = StringSplit($sActions, @CRLF, $STR_NOCOUNT + $STR_ENTIRESPLIT) ; code end $iT = TimerDiff($iT) $Sum += $iT $QuSum += $iT * $iT If $iT < $min Then $min = $iT If $iT > $max Then $max = $iT Next $f_StdDev = Sqrt(($QuSum - ($Sum ^ 2) / $i_Runs) / ($i_Runs - 1)) $f_StdErr = $f_StdDev / Sqrt($i_Runs) $a_Results[UBound($a_Results) - 1][1] = $Sum / $i_Runs $a_Results[UBound($a_Results) - 1][3] = $f_StdDev $a_Results[UBound($a_Results) - 1][4] = $f_StdErr $a_Results[UBound($a_Results) - 1][5] = $min $a_Results[UBound($a_Results) - 1][6] = $max $a_Results[UBound($a_Results) - 1][7] = $max - $min ; stringregexp only Global $Sum = 0, $QuSum = 0, $min = 1e15, $max = 0, $iT ReDim $a_Results[UBound($a_Results) + 1][8] $a_Results[UBound($a_Results) - 1][0] = "StringRegExp only" For $i = 1 To $i_Runs $iT = TimerInit() ; code start $aRE = StringRegExp($sString, '(?sm)^\s*"' & $what & '"\s*:([^\]]+)', 1) $aActions = StringRegExp($aRE[0], '"([^"]+)"', 3) ;~ _DebugArrayDisplay($aActions) ; code end $iT = TimerDiff($iT) $Sum += $iT $QuSum += $iT * $iT If $iT < $min Then $min = $iT If $iT > $max Then $max = $iT Next $f_StdDev = Sqrt(($QuSum - ($Sum ^ 2) / $i_Runs) / ($i_Runs - 1)) $f_StdErr = $f_StdDev / Sqrt($i_Runs) $a_Results[UBound($a_Results) - 1][1] = $Sum / $i_Runs $a_Results[UBound($a_Results) - 1][3] = $f_StdDev $a_Results[UBound($a_Results) - 1][4] = $f_StdErr $a_Results[UBound($a_Results) - 1][5] = $min $a_Results[UBound($a_Results) - 1][6] = $max $a_Results[UBound($a_Results) - 1][7] = $max - $min ; calculate results and print them out _ArraySort($a_Results, 0, 0, 0, 1) For $i = 0 To UBound($a_Results) - 1 $a_Results[$i][2] = Round($a_Results[$i][1] / $a_Results[0][1], 2) For $j = 1 To 7 $a_Results[$i][$j] = Round($a_Results[$i][$j], $f_DecimalPlaces) Next Next ;~ _ArrayDisplay($a_Results, "Results over " & $i_Runs & " loops", "", 16 + 64, Default, "name|time[ms]|factor|Std. Dev|Std. Err.|min|max|range") ;~ #include <SQLite.au3> ConsoleWriteResult() Func ConsoleWriteResult() ConsoleWrite(@CRLF & RegRead("HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString") & _ " | Runs: " & $i_Runs & " | Entry: """ & $what & """ | Count: " & $whatCount & " | WinVer: " & FileGetVersion("WinVer.exe") & @CRLF & @CRLF) Local $aHead = StringSplit("name|time[ms]|factor|Std. Dev|Std. Err.|min|max|range", "|", 2) ; header from _ArrayDisplay() ReDim $a_Results[UBound($a_Results) + 2][UBound($a_Results, 2)] For $n = UBound($a_Results) - 3 To 0 Step -1 For $m = 0 To UBound($a_Results, 2) - 1 $a_Results[$n + 2][$m] = $a_Results[$n][$m] Next Next For $m = 0 To UBound($a_Results, 2) - 1 $a_Results[0][$m] = $aHead[$m] $a_Results[1][$m] = "------" Next _SQLite_Display2DResult($a_Results, 0, False, "|", "|" & @CRLF) EndFunc ;==>ConsoleWriteResult I got to see what is what ( to a degree ) expandcollapse popupIntel(R) Pentium(R) Silver N6000 @ 1.10GHz | Runs: 100 | Entry: "copilot" | Count: 15 | WinVer: 10.0.14393.0 name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 1.151 | 1 | 0.039 | 0.004 | 1.102 | 1.281 | 0.179 | JsonC-UDF | 2.664 | 2.31 | 0.919 | 0.092 | 2.157 | 8.052 | 5.894 | jq UDF | 46.975 | 40.81 | 2.475 | 0.248 | 44.542 | 55.569 | 11.027 | pure AutoIt JSON-UDF | 217.143 | 188.66 | 4.757 | 0.476 | 206.448 | 236.374 | 29.926 | JSMN-based JSON-UDF | 237.231 | 206.11 | 7.779 | 0.778 | 228.528 | 279.891 | 51.364 | Intel(R) Pentium(R) Silver N6000 @ 1.10GHz | Runs: 100 | Entry: "actions" | Count: 5061 | WinVer: 10.0.14393.0 name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 3.585 | 1 | 0.205 | 0.021 | 3.261 | 4.168 | 0.907 | jq UDF | 52.809 | 14.73 | 1.572 | 0.157 | 50.744 | 58.847 | 8.104 | JsonC-UDF | 116.794 | 32.58 | 5.827 | 0.583 | 112.52 | 158.619 | 46.099 | pure AutoIt JSON-UDF | 221.849 | 61.88 | 3.665 | 0.367 | 216.139 | 239.11 | 22.971 | JSMN-based JSON-UDF | 235.16 | 65.6 | 4.233 | 0.423 | 227.894 | 251.581 | 23.687 | 12th Gen Intel(R) Core(TM) i9-12900H | Runs: 100 | Entry: "copilot" | Count: 15 | WinVer: 11 pro name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 0.692 | 1 | 0.17 | 0.017 | 0.547 | 1.215 | 0.668 | JsonC-UDF | 1.098 | 1.59 | 0.203 | 0.02 | 0.882 | 1.88 | 0.998 | jq UDF | 30.073 | 43.46 | 2.542 | 0.254 | 26.073 | 36.233 | 10.161 | pure AutoIt JSON-UDF | 98.456 | 142.28 | 5.62 | 0.562 | 87.521 | 116.823 | 29.301 | JSMN-based JSON-UDF | 107.644 | 155.55 | 6.317 | 0.632 | 94.134 | 125.391 | 31.257 | 12th Gen Intel(R) Core(TM) i9-12900H | Runs: 100 | Entry: "actions" | Count: 5061 | WinVer: 11 pro name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 1.852 | 1 | 0.403 | 0.04 | 1.364 | 3.101 | 1.738 | jq UDF | 34.722 | 18.75 | 2.798 | 0.28 | 29.726 | 42.913 | 13.187 | JsonC-UDF | 52.277 | 28.23 | 3.896 | 0.39 | 45.481 | 64.209 | 18.728 | pure AutoIt JSON-UDF | 101.908 | 55.03 | 5.282 | 0.528 | 92.217 | 121.343 | 29.127 | JSMN-based JSON-UDF | 111.208 | 60.05 | 6.03 | 0.603 | 101.079 | 133.279 | 32.201 | and ... I should learn RegEx ( nah, too hard. I'll keep shamelessly copy'n'pasteing ). But am satisfied with the results, and it now makes sense to me how a 61 kb DLL vs 962 kb EXE fare against each other given the conditions. ( understood that one is a general purpose library/DLL while the other a highly optimized program for it ) Edited Wednesday at 11:25 PM by argumentum more Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
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