all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
35
Task/Time-a-function/Icon/time-a-function-1.icon
Normal file
35
Task/Time-a-function/Icon/time-a-function-1.icon
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
procedure timef(f) #: time a function f
|
||||
local gcol,alloc,used,size,runtime,header,x,i
|
||||
|
||||
title := ["","total","static","string","block"] # headings
|
||||
collect() # start with collected memory (before baseline)
|
||||
every put(gcol := [], -&collections) # baseline collections count
|
||||
every put(alloc := [], -&allocated) # . total allocated space by region
|
||||
every put(used := [], -&storage) # . currently used space by region - no total
|
||||
every put(size := [], -®ions) # . current size of regions - no total
|
||||
|
||||
write("Performance and Timing measurement for ",image(f),":")
|
||||
runtime := &time # base time
|
||||
f()
|
||||
write("Execution time=",&time-runtime," ms.")
|
||||
|
||||
every (i := 0, x := &collections) do gcol[i +:= 1] +:= x
|
||||
every (i := 0, x := &allocated ) do alloc[i +:= 1] +:= x
|
||||
every (i := 0, x := &storage ) do used[i +:= 1] +:= x
|
||||
every (i := 0, x := ®ions ) do size[i +:= 1] +:= x
|
||||
|
||||
push(gcol,"garbage collections:")
|
||||
push(alloc,"memory allocated:")
|
||||
push(used,"N/A","currently used:")
|
||||
push(size,"N/A","current size:")
|
||||
|
||||
write("Memory Region and Garbage Collection Summary (delta):")
|
||||
every (i := 0) <:= *!(title|gcol|alloc|used|size)
|
||||
every x := (title|gcol|alloc|used|size) do {
|
||||
f := left
|
||||
every writes(f(!x,i + 3)) do f := right
|
||||
write()
|
||||
}
|
||||
write("Note: static region values should be zero and may not be meaningful.")
|
||||
return
|
||||
end
|
||||
6
Task/Time-a-function/Icon/time-a-function-2.icon
Normal file
6
Task/Time-a-function/Icon/time-a-function-2.icon
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
procedure main()
|
||||
timef(perfectnumbers)
|
||||
end
|
||||
|
||||
procedure perfectnumbers()
|
||||
...
|
||||
Loading…
Add table
Add a link
Reference in a new issue