Leaderboard
Popular Content
Showing content with the highest reputation on 03/10/2017 in all areas
-
Do you have unlimited memory in your Computer? Give it a go and see what happens. Jos1 point
-
SaeidN, No doubt you have reached the Windows character limit for the edit control - use _GUICtrlEdit_SetLimitText to increase it. M231 point
-
It actually looks like it is an ASCII highvalue character and not a UTF character. This character has an ASCII 130 value so this should work: $stdoutRead = StringReplace($stdoutRead, chr(130), "é") ;why not replaced Jos1 point
-
No idea what that means. what exactly do you mean or want to do? Jos1 point
-
This has everything to do with character encoding. I have attached the same script with 2 different StringReplace() statements. the first doesn't work and the second works and that is because the first one has an ASCII COMMA and the second an UTF8 COMMA. Give it a try. Jos test.au31 point
-
Sorry, but that doesn't answer my question. what exactly are you trying to accomplish? what is the exact content of the STDOUT #include <WinAPIFiles.au3> $stdoutRead = _CmdResult('netsh mbn show interface') ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $stdoutRead = ' & $stdoutRead & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $stdoutRead = StringReplace($stdoutRead, ",", "é") ;why not replaced ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $stdoutRead = ' & $stdoutRead & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console MsgBox(0, "", $stdoutRead) Func _CmdResult($Commands) Local $Message Local $DOS = Run(@ComSpec & " /c " & $Commands, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($DOS) $Message = StdoutRead($DOS) Return $Message EndFunc ;==>_CmdResult Jos1 point
-
Any character or do you mean a COMMA as that is what you have defined in the StringReplace() command? Jos1 point
-
1 point
-
When possible and with the usual precautions, this approach (much faster) looks better #Include <Array.au3> $sTarget = "https://www.amazon.it/s/ref=nb_sb_noss?__mk_it_IT=%C3%85M%C3%85%C5%BD%C3%95%C3%91&url=search-alias%3Daps&field-keywords=" & "i7" $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("GET", $sTarget, False) $oHTTP.Send() $s = BinaryToString($oHTTP.ResponseText) $oHTTP = 0 ;filewrite("1.txt", $s) Local $aL = StringRegExp($s, '(?s)href="([^"]+)"><img src="([^"]+)"\h*srcset="[^"]+.*?title="([^"]+)" href="', 3) _ArrayDisplay($aL)1 point
-
You are using the wrong flag for StringStripWS. Please check the help file for the proper flag to remove leading/trailing and doubl whitespace. The user could enter a separator character and enter multiple file numbers this way e.g. "number1;number2;number3". Then use StringSplit to retrieve each file number.1 point
-
Array read speed vs variable made from array
Triblade reacted to jvanegmond for a topic
Your gist understanding is correct. Except when the array is too large to fit, for example it spans 1 contiguous block of 100MB, this array will just be read into the CPU cache at page-size blocks at a time based on the subscripts you are accessing. This is why sequentially accessing an array is faster than randomly accessing it. The data for the next element will already be in cache. The test which spudw2k did unfortunately has some problems which make interpreting any meaningful result from it difficult. The array is reinitialized and then accessed immediately after, which can leave the array in the cache. But this depends on CPU make & model. Random numbers are generated in a non-deterministic way, which can affect the outcome of each new test. 10 samples taken is not nearly enough to eliminate random noise, from other programs and the operating system. Probably TimerInit/TimerDiff should be replaced for all such performance measurement scenarios with a straight up call to a QueryPerformanceCounter function, but then DllCall is kinda slow too so it's a lesser of evils decision. There are more problems, none are easy to really properly compensate for. AutoIt is in this sense not designed with such small performance thoughts in mind. It's better to focus on things we know which will have an affect on performance. Having the data already in cache is referred to as locality of reference and can help in a big way in your initial example. It shouldn't really matter if you copied it into a temporary variable or are accessing it directly, it matters that its in cache or no.1 point -
Array read speed vs variable made from array
Xandy reacted to jvanegmond for a topic
Triblade, what an interesting question. Under the waters, any array is just an address of where to start finding the values in memory. Say you're storing 32-bit integers in an array, this will be stored in a contiguous block of memory. If we were to look at the memory, it would look like: base address (start) and then 4 bytes integer, 4 bytes integer, 4 bytes integer, and so on. If the base address of this array is 50, array index 2 is going to be at 50 + (2 x 4) where 4 is the size in bytes of the integer. In statically typed languages, the number of bytes for your value is determined at compile time so this can be 'baked' into the program to avoid any calculations. In AutoIt, a dynamically typed language, there exists something called a variant (based on 2005 source but probably not changed) which can store any type of data: Int, long, double, window handle, and such small data types easily fit in the variant structure. These are stored sequentially for optimization reasons with a minor overhead. Large values such as strings are stored in another location and the variant simply holds the address to this string memory, so this types of data are exceptional and should be considered carefully when thinking about performance. Multidimensional arrays get turned into flat arrays, where the indexes are multiplied by one another. So $closed[3][4] is just $closed base address + ((3 * 4) * 4). Again taking 4 bytes for each integer. So you can consider $closed[3][4] to be another syntax for $closed[3*4]. This is really not a special case for the underlying language. The CPU is incredibly fast. He always copies data from RAM to cache in sizes which are called a block. This is mostly 4K of memory at once copied from RAM, which take about 120+ CPU cycles to get into cache. Modern CPU have 3 levels of cache, called L3, L2 and L1. Depending on manufacturer, these caches have different sizes and this is a large contributor into what makes some modern CPU's feel fast and some slow apart from just raw clock speed. Accessing arrays requires the CPU to multiply the indexes and then get the whole block of memory into cache. Multiplying the dimensions for your array in your script, 0 by 0, is trivial. This takes only 1 or 2 CPU cycles. Actually retrieving the memory from RAM takes 120+ cycles. Once this memory is in cache, it will take less than 20 CPU cycles to retrieve it again. How do we know if memory is still in cache? This depends on a lot of factors, but the main factor here is your operating system. Your operating system slices the total CPU time up into what are called slices. Each thread on the operating system gets a time slice according to some prioritization mechanism. Familiarity with this might include opening up task manager, seeing the total amount of threads on the system, and changing the priority of a process to High or Realtime. Now do not be alarmed at the 2000+ something threads running on your system. A vast majority of these threads are in sleep mode, and the scheduler simply skips over them. Our program will be executing within one of these time slices. This means at the start of the time slice, our CPU will get RAM into cache and will as quickly as possible execute our program. The realistic expected time frame of accesses to the same point in memory should be around 120 cycles for the first access and 20 cycles afterwards. As long as we write our code in tight loops, where we are not voluntarily relinquishing CPU time back to the operating system when we are waiting for something, our data should still be in cache. Realistically, data still being in cache is determined by a cache eviction policy/algorithm and there is really nothing you can do about this other than not submit to thread switches and perhaps write a nice letter to Intel/AMD where you offer a couple of beers and to sacrifice a goat. Each vendor individually has their own cache eviction policy and I believe in x86 or x86-64 these are not standardized and therefore make for a source of competition for these companies.(Citation needed) Strings and large memory structures are special. In this case, the variant does not hold the data directly but holds a reference to where the data is really stored. This means the CPU must get the array from memory, which points to other blocks of memory which must also be gotten from RAM. This means not only one of those terrible 120+ cycle accesses, but several, just to access one item. There is really no good solution for this with arrays. Other data types which allow elements to be of non-uniform length might be better suited for the application. This is more or less the same for statically typed languages. THIS COVERS ARRAY ACCESS. Now keep in mind that code is just another form of data. The code must also be read into CPU cache before it can be executed. If the AutoIt language makes some bad choices regarding caches; this will severely impact performance and may invalidate some or all of the above. For example, code pointing to other code, to other code, which must all be gotten from cache in sequence is going to make a practical program - which follows all the correct performance guidelines - very, very slow. This is why the community prefers to do benchmarks - but there's nothing wrong with a little theory from time to time. I believe AutoIt to do this mostly pretty OK in practice. The AutoIt source from 2005 seems to confirm this and that's really the best I can do on this part. Disclaimer: I've had to dumb this down, and only somewhat reflects the intricacies of modern computing.1 point -
had to adjust fire on the command again. The last version only inserts the picture into the first frame, this one will set the picture in every frame, for the duration of the song. $pic = "picture.jpg" $song = "song.mp3" $result = "result.avi" runwait ("cmd /k ffmpeg -f image2 -loop 1 -i " & $pic & " -vcodec flv -i " & $song & " -acodec copy -qscale 2 -g 5 -cmp 3 -subcmp 3 -mbd 2 -shortest " & $result, @ScriptDir)1 point