<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title>Форум QUIK [тема: debugger]</title>
		<link>http://forum.quik.ru</link>
		<description>Новое в теме debugger форума  на сайте Форум QUIK [forum.quik.ru]</description>
		<language>ru</language>
		<docs>http://backend.userland.com/rss2</docs>
		<pubDate>Sat, 02 May 2026 22:32:11 +0300</pubDate>
		<item>
			<title>debugger</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message32662/topic3875/">debugger</a></b> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			На просторах интернета есть скрипт на основе debug-библиотеки, встроенной в Луа. <br /><noindex><a href="https://stackoverflow.com/questions/15725744/easy-lua-profiling" target="_blank" rel="nofollow">https://stackoverflow.com/questions/15725744/easy-lua-profiling</a></noindex><br />Я - увы - ничего не понимаю в этом коде, но моих слабых способностей хватило, чтобы начать его использовать.<br />До начала отслеживаемого куска ставится код:<br />
====code====
<pre>local calls, total, this = {}, {}, {}debug.sethook(function(event)
&nbsp;&nbsp;local i = debug.getinfo(2, "Sln")
&nbsp;&nbsp;if i.what ~= 'Lua' then return end
&nbsp;&nbsp;local func = i.name or (i.source..':'..i.linedefined)
&nbsp;&nbsp;if event == 'call' then
&nbsp;&nbsp;&nbsp;&nbsp;this&#91;func&#93; = os.clock()
&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;local time = os.clock() - this&#91;func&#93;
&nbsp;&nbsp;&nbsp;&nbsp;total&#91;func&#93; = (total&#91;func&#93; or 0) + time
&nbsp;&nbsp;&nbsp;&nbsp;calls&#91;func&#93; = (calls&#91;func&#93; or 0) + 1
&nbsp;&nbsp;end
end, "cr")
</pre>
=============
--изучаемый код<br /><br />Концовка:<br />
====code====
<pre>debug.sethook()
-- print the results
for f,time in pairs(total) do
&nbsp;&nbsp;print(("Function %s took %.3f seconds after %d calls"):format(f, time, calls&#91;f&#93;))
end</pre>
=============
вместо print я вывожу эту строку в файл.<br /><br />Скрипт работает и внутри колбека OnQuote показывает мои &quot;личные&quot; функции:<br /><br /><img src="http://dl3.joxi.net/drive/2018/08/10/0011/1313/742689/89/33c4c21857.png" alt="Пользователь добавил изображение" border="0" /><br /><br />Но самое ценное - функцию получения стакана getQuoteLevel2 не показывает. Видимо, он понимает только пользовательские функции.<br />Прошу подсказать, как в этот дебаггер добавить другую полезную информацию:<br />--функции QLUA<br />--пробегание циклов<br />--переменные<br />Спасибо за советы. <br />
			<i>10.08.2018 21:31:37, Let_it_go.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message32662/topic3875/</link>
			<guid>http://forum.quik.ru/messages/forum10/message32662/topic3875/</guid>
			<pubDate>Fri, 10 Aug 2018 21:31:37 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
	</channel>
</rss>
