September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
30
Task/Function-frequency/Phix/function-frequency.phix
Normal file
30
Task/Function-frequency/Phix/function-frequency.phix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
constant func_log = new_dict(),
|
||||
func_freq = new_dict()
|
||||
|
||||
global procedure log_function_call(integer rtnNo)
|
||||
integer node = getd_index(rtnNo,func_log)
|
||||
setd(rtnNo,iff(node=NULL?1:getd_by_index(node,func_log)+1),func_log)
|
||||
end procedure
|
||||
|
||||
include p.exw -- the phix compiler, full source
|
||||
|
||||
-- invert the dictionary, then print top ten
|
||||
|
||||
integer count = 0
|
||||
function visitor(object key, integer data, integer user_data)
|
||||
if user_data=1 then -- invert
|
||||
setd({data,key},0,func_freq)
|
||||
else
|
||||
key[2] = symtab[key[2]][S_Name]
|
||||
?key
|
||||
count += 1
|
||||
if count>10 then return 0 end if -- cease traversal
|
||||
end if
|
||||
return 1
|
||||
end function
|
||||
constant r_visitor = routine_id("visitor")
|
||||
|
||||
rebuild_callback() -- (convert ternary tree indexes to readable names)
|
||||
|
||||
traverse_dict(r_visitor,1,func_log) -- invert
|
||||
traverse_dict(r_visitor,2,func_freq,rev:=true) -- top 10
|
||||
Loading…
Add table
Add a link
Reference in a new issue