[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: question on debug hooks
- From: Paul K <paulclinger@...>
- Date: Fri, 5 Apr 2013 18:00:39 -0700
Hi Thijs,
> Now when running with the different debug mask and count values I expected to see large differences in both counters. But there aren't.
...
> debug.sethook(hook, mask, count)
I think mask and count are mutually exclusive; in other words, if you
have "c", 100, it doesn't mean that it will be called every 100th
"call" event. I may be mistaken, but last time I checked, count
behaves like a line event with a threshold.
So, sethook(hook, "r", 100) is the same as sethook(hook, "r"). If you
want to get every Nth statement, then try sethook(hook, "", N):
test("", nil)
test("", 100)
test("", 1000)
test("", 50000)
With nil
loop count : 4036736
check count: 0
With 100
loop count : 3575464
check count: 335199
With 1000
loop count : 3100648
check count: 28017
With 50000
loop count : 4043297
check count: 727
Paul.
On Fri, Apr 5, 2013 at 9:33 AM, Thijs Schreijer <thijs@thijsschreijer.nl> wrote:
> List,
>
> I have some behavior I can't explain using a debug hook.
> I created a small test. Both the function running and the debug hook only contain a counter.
> Now when running with the different debug mask and count values I expected to see large differences in both counters. But there aren't.
>
> These are the mask and count values and the counts returned:
> With c nil
> loop count : 2888804
> check count: 2888813
> With c 100
> loop count : 2219481
> check count: 2404448
> With c 1000
> loop count : 2480837
> check count: 2493768
> With c 50000
> loop count : 2410984
> check count: 2411308
> With r nil
> loop count : 2229461
> check count: 2229473
> With r 100
> loop count : 2019846
> check count: 2188178
> With r 1000
> loop count : 2162406
> check count: 2173679
> With r 50000
> loop count : 2325529
> check count: 2325842
> With l nil
> loop count : 2111964
> check count: 2111971
> With l 100
> loop count : 2001379
> check count: 2168168
> With l 1000
> loop count : 2106344
> check count: 2117323
> With l 50000
> loop count : 2089613
> check count: 2089893
>
> Especially with values "l" and 50000, I would have expected the debug counter to be far lower than the loop counter.
> What am I missing? Any help is appreciated.
>
> Thijs
>
> Test script below
>
>
> local gettime = require("socket").gettime
> local t, loopcount, checkcount
>
> local loop = function()
> while t+1>gettime() do loopcount = loopcount + 1 end
> end
>
> local hook = function() checkcount = checkcount + 1 end
>
> local test = function(mask, count)
> loopcount = 0
> checkcount = 0
> t = gettime()
> debug.sethook(hook, mask, count)
> loop()
> print("With",mask,count)
> print(" loop count :",loopcount)
> print(" check count:", checkcount)
> end
>
> test("c", nil)
> test("c", 100)
> test("c", 1000)
> test("c", 50000)
> test("r", nil)
> test("r", 100)
> test("r", 1000)
> test("r", 50000)
> test("l", nil)
> test("l", 100)
> test("l", 1000)
> test("l", 50000)
>
>
>
>
>