<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title>Форум QUIK [тема: os.sysdate()]</title>
		<link>http://forum.quik.ru</link>
		<description>Новое в теме os.sysdate() форума  на сайте Форум QUIK [forum.quik.ru]</description>
		<language>ru</language>
		<docs>http://backend.userland.com/rss2</docs>
		<pubDate>Fri, 17 Apr 2026 04:18:25 +0300</pubDate>
		<item>
			<title>os.sysdate()</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message81882/topic9509/">os.sysdate()</a></b> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			При системном таймере 1 ms os.sysdate() &quot;тикает&quot; не равномерно.<br /><br />
====code====
<pre>&nbsp;&nbsp;local function difftime(t1, t2)
&nbsp;&nbsp;&nbsp;&nbsp;return os.time(t1) - os.time(t2) + (t1.mcs - t2.mcs) / 1000000
&nbsp;&nbsp;end

&nbsp;&nbsp;local n = 0
&nbsp;&nbsp;local sum = 0
&nbsp;&nbsp;local max = 0
&nbsp;&nbsp;local min
&nbsp;&nbsp;while run do
&nbsp;&nbsp;&nbsp;&nbsp;local t1 = os.sysdate()
&nbsp;&nbsp;&nbsp;&nbsp;local t2 = os.sysdate()
&nbsp;&nbsp;&nbsp;&nbsp;while t1.mcs == t2.mcs do t2 = os.sysdate() end
&nbsp;&nbsp;&nbsp;&nbsp;local dt = difftime(t2, t1) * 1000
&nbsp;&nbsp;&nbsp;&nbsp;--message(string.format("%.3f ms", dt))
&nbsp;&nbsp;&nbsp;&nbsp;n = n + 1
&nbsp;&nbsp;&nbsp;&nbsp;sum = sum + dt
&nbsp;&nbsp;&nbsp;&nbsp;if dt &#62; max then max = dt end
&nbsp;&nbsp;&nbsp;&nbsp;if min == nil or dt &#60; min then min = dt end
&nbsp;&nbsp;&nbsp;&nbsp;sleep(1)
&nbsp;&nbsp;end
&nbsp;&nbsp;message(string.format("avg: %.3f;&nbsp;&nbsp;max: %.3f;&nbsp;&nbsp;min: %.3f", sum / n, max, min))</pre>
=============
<br />Результат в Win11:<br />
====code====
<pre>avg: 1.049;&nbsp;&nbsp;max: 6.480;&nbsp;&nbsp;min: 0.067</pre>
=============
Т.е., шаг меняется от 67 мкс до 6,4 с <br />
			<i>05.03.2026 18:53:35, Йцукен.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message81882/topic9509/</link>
			<guid>http://forum.quik.ru/messages/forum10/message81882/topic9509/</guid>
			<pubDate>Thu, 05 Mar 2026 18:53:35 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>os.sysdate()</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message81851/topic9509/">os.sysdate()</a></b> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Если также считать разницу между os.time() и os.clock(), то дельта не меняется при перезапуске скрипта. <br />
			<i>04.03.2026 14:20:18, Йцукен.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message81851/topic9509/</link>
			<guid>http://forum.quik.ru/messages/forum10/message81851/topic9509/</guid>
			<pubDate>Wed, 04 Mar 2026 14:20:18 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>os.sysdate()</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message81850/topic9509/">os.sysdate()</a></b> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			os.time() меняется на несколько мс раньше os.sysdate()<br />Ниже разница между os.time() в момент смены секунды и os.sysdate() (при системном таймере 15.625 ms).<br /><br />
====code====
<pre>&nbsp;&nbsp;for i = 1, 10 do
&nbsp;&nbsp;&nbsp;&nbsp;local t
&nbsp;&nbsp;&nbsp;&nbsp;local t0 = os.time()
&nbsp;&nbsp;&nbsp;&nbsp;repeat t = os.time() until t0 ~= t
&nbsp;&nbsp;&nbsp;&nbsp;local s = os.sysdate()
&nbsp;&nbsp;&nbsp;&nbsp;message(string.format("%.3f ms", 1000 * (t - os.time(s)) - s.mcs / 1000))
&nbsp;&nbsp;end
</pre>
=============
<br />Каждый блок - отдельный запуск скрипта в одном и том же терминале.<br /><table class="forum-spoiler"><thead onclick="if (this.nextSibling.style.display=='none') { this.nextSibling.style.display=''; BX.addClass(this, 'forum-spoiler-head-open'); } else { this.nextSibling.style.display='none'; BX.removeClass(this, 'forum-spoiler-head-open'); } BX.onCustomEvent('BX.Forum.Spoiler:toggle', [{node: this}]); event.stopPropagation();"><tr><th><div>Скрытый текст</div></th></tr></thead><tbody class="forum-spoiler" style="display:none;"><tr><td>14.518 ms<br />14.472 ms<br />14.517 ms<br />14.517 ms<br />14.517 ms<br />14.517 ms<br />14.478 ms<br />14.517 ms<br />14.473 ms<br />14.517 ms</td></tr></tbody></table><table class="forum-spoiler"><thead onclick="if (this.nextSibling.style.display=='none') { this.nextSibling.style.display=''; BX.addClass(this, 'forum-spoiler-head-open'); } else { this.nextSibling.style.display='none'; BX.removeClass(this, 'forum-spoiler-head-open'); } BX.onCustomEvent('BX.Forum.Spoiler:toggle', [{node: this}]); event.stopPropagation();"><tr><th><div>Скрытый текст</div></th></tr></thead><tbody class="forum-spoiler" style="display:none;"><tr><td>7.808 ms<br />7.805 ms<br />7.849 ms<br />7.808 ms<br />7.809 ms<br />7.810 ms<br />7.804 ms<br />7.807 ms<br />7.798 ms<br />7.298 ms</td></tr></tbody></table><table class="forum-spoiler"><thead onclick="if (this.nextSibling.style.display=='none') { this.nextSibling.style.display=''; BX.addClass(this, 'forum-spoiler-head-open'); } else { this.nextSibling.style.display='none'; BX.removeClass(this, 'forum-spoiler-head-open'); } BX.onCustomEvent('BX.Forum.Spoiler:toggle', [{node: this}]); event.stopPropagation();"><tr><th><div>Скрытый текст</div></th></tr></thead><tbody class="forum-spoiler" style="display:none;"><tr><td>3.062 ms <br />3.062 ms <br />3.104 ms <br />3.060 ms <br />3.062 ms <br />3.062 ms <br />3.058 ms <br />3.104 ms <br />2.679 ms <br />2.682 ms </td></tr></tbody></table><table class="forum-spoiler"><thead onclick="if (this.nextSibling.style.display=='none') { this.nextSibling.style.display=''; BX.addClass(this, 'forum-spoiler-head-open'); } else { this.nextSibling.style.display='none'; BX.removeClass(this, 'forum-spoiler-head-open'); } BX.onCustomEvent('BX.Forum.Spoiler:toggle', [{node: this}]); event.stopPropagation();"><tr><th><div>Скрытый текст</div></th></tr></thead><tbody class="forum-spoiler" style="display:none;"><tr><td>14.115 ms<br />14.078 ms<br />14.117 ms<br />14.116 ms<br />14.116 ms<br />14.118 ms<br />14.116 ms<br />14.116 ms<br />14.116 ms<br />14.116 ms</td></tr></tbody></table><br />Почему при перезапуске скрипта дельта меняется? <br />
			<i>04.03.2026 14:07:05, Йцукен.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message81850/topic9509/</link>
			<guid>http://forum.quik.ru/messages/forum10/message81850/topic9509/</guid>
			<pubDate>Wed, 04 Mar 2026 14:07:05 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
	</channel>
</rss>
