<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Сортировка массива]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=18289</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=18289&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Сортировка массива».]]></description>
		<lastBuildDate>Wed, 28 Aug 2024 16:04:15 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161540#p161540</link>
			<description><![CDATA[<p>Да, странно, у меня вчера вроде показывало прирост. Но и от SetCapacity результат не особо значительный, у меня:<br />8300 - 8500<br />8100 - 8300<br />7600 - 7900</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 28 Aug 2024 16:04:15 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161540#p161540</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161539#p161539</link>
			<description><![CDATA[<div class="codebox"><pre><code>SetBatchLines, -1

arr := []
arr.SetCapacity(100000000) 
Loop 100000 {
    Random, rand
    arr.Push({value: rand})
}

a := A_TickCount
SortDescending(arr, &quot;value&quot;)
msgbox % A_TickCount - a

a := A_TickCount
SortDescending1(arr, &quot;value&quot;)
msgbox % A_TickCount - a

a := A_TickCount
SortDescending2(arr, &quot;value&quot;)
msgbox % A_TickCount - a


SortDescending(arr, key, sort = &quot;R N&quot;, del = &quot;|&quot;) {
	res := [], ex := {}, str := &quot;&quot; 
	for k, v in arr {
		str .= v[key] del
		If !ex[v[key]]
			ex[v[key]] := []
		ex[v[key]].push(k)
	}
	Sort str, U D%del% Z %sort%
	Loop, Parse, str, %del%
	{
		for k, v in ex[A_LoopField]  
			res.push(arr[v])
	} 
	Return res 
}


SortDescending1(arr, key, sort = &quot;R N&quot;, del = &quot;|&quot;) {
	res := [], ex := {}, str := &quot;&quot; 
; res.SetCapacity(100000000) 
 VarSetCapacity(str, 100000000)
	for k, v in arr {
		str .= v[key] del
		If !ex[v[key]]
			ex[v[key]] := []
		ex[v[key]].push(k)
	}
	Sort str, U D%del% Z %sort%
	Loop, Parse, str, %del%
	{
		for k, v in ex[A_LoopField]  
			res.push(arr[v])
	} 
	Return res 
}

SortDescending2(arr, key, sort = &quot;R N&quot;, del = &quot;|&quot;) {
	res := [], ex := {}, str := &quot;&quot; 
 res.SetCapacity(100000000) 
; VarSetCapacity(str, 100000000)
	for k, v in arr {
		str .= v[key] del
		If !ex[v[key]]
			ex[v[key]] := []
		ex[v[key]].push(k)
	}
	Sort str, U D%del% Z %sort%
	Loop, Parse, str, %del%
	{
		for k, v in ex[A_LoopField]  
			res.push(arr[v])
	} 
	Return res 
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 28 Aug 2024 15:35:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161539#p161539</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161537#p161537</link>
			<description><![CDATA[<p>Почему не ускорит? У меня раза в полтора ускоряет на большом массиве.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 28 Aug 2024 14:42:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161537#p161537</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161536#p161536</link>
			<description><![CDATA[<p>Ну, сильно оно не ускорит.<br />res.SetCapacity() побольше ускорения даст.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 28 Aug 2024 13:16:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161536#p161536</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161535#p161535</link>
			<description><![CDATA[<p>Да, формирование строки. Я имел в виду ускорить пример с использованием Sort.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 28 Aug 2024 09:08:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161535#p161535</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161534#p161534</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Кстати, чтобы ускорить использование Sort, нужно добавить VarSetCapacity.</p></blockquote></div><p>А с чем это связано, перед тем как попасть в Sort она ведь и так имеет нужный размер, а чтобы прикинуть размер, надо ещё раз массив перебрать. То есть массив перебирать и вычислять быстрее, чем при каждом добавлении в строку расширять её память. Если так то это не касается именно Sort, а это в общем так. Ну то есть не ускорить Sort, а ускорить формирование строки.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 28 Aug 2024 08:37:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161534#p161534</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161533#p161533</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Пример можно</p></blockquote></div><div class="codebox"><pre><code>    VarSetCapacity(str, ...) ; здесь прикинуть, сколько может потребоваться
	for k, v in arr {
		str .= v[key] del
		If !ex[v[key]]
			ex[v[key]] := []
		ex[v[key]].push(k)
	}
	Sort str, U D%del% Z %sort%</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 27 Aug 2024 19:51:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161533#p161533</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161532#p161532</link>
			<description><![CDATA[<p>Не, просто решил попробовать проверить с одинаковыми числами.<br /><a href="https://claude.ai/">https://claude.ai/</a></p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Tue, 27 Aug 2024 17:05:20 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161532#p161532</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161531#p161531</link>
			<description><![CDATA[<p><strong>Malcev</strong><br />Это ты понял код, чтобы понять как сделать такой тест?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 27 Aug 2024 17:02:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161531#p161531</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161530#p161530</link>
			<description><![CDATA[<p>Эх, ё моё блин... Ху из &quot;Клод&quot;? Моне...</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 27 Aug 2024 16:53:06 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161530#p161530</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161529#p161529</link>
			<description><![CDATA[<p>А с такими данными:<br /></p><div class="codebox"><pre><code>Loop 10000 {
    arr.Push({value: 1})
}</code></pre></div><p>в 1890 раз &quot;Клод&quot; тормознутее. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Tue, 27 Aug 2024 16:28:21 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161529#p161529</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161528#p161528</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Кстати, чтобы ускорить использование Sort, нужно добавить VarSetCapacity</p></blockquote></div><p>Пример можно.</p><br /><p>На 1000 ключей оно уже в 3 раза проигрывает, так что тут надо ещё от задачи отталкиваться, для частого перебора небольших массивов не катит.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 27 Aug 2024 15:41:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161528#p161528</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161527#p161527</link>
			<description><![CDATA[<p>Чем больше массив, тем больше проявляется польза алгоритма. Кстати, чтобы ускорить использование Sort, нужно добавить VarSetCapacity.<br /></p><div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Тут уже совсем другой код</p></blockquote></div><p>Это всё ещё QuickSort, который, насколько я помню, используется и в Sort. Но там есть разные модификации.<br /></p><div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Тут я так понял жпт постарался.</p></blockquote></div><p>Не, это был Клод. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 27 Aug 2024 13:39:06 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161527#p161527</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161525#p161525</link>
			<description><![CDATA[<p>Но на 50000 ключей с Sort быстрее, на 60000 примерно вровень.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 27 Aug 2024 13:12:08 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161525#p161525</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сортировка массива]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=161524#p161524</link>
			<description><![CDATA[<p>Тут уже совсем другой код, опроверг сам себя что Sort не перебить.<br />4000 против 5500 с Sort, и против <strong>20000</strong> без Sort, не ожидал. </p><p>Тут я так понял жпт постарался. <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 27 Aug 2024 13:05:34 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=161524#p161524</guid>
		</item>
	</channel>
</rss>
