summaryrefslogtreecommitdiff
path: root/bench_lmx2487.lua
blob: d1221d4c27878454d711da0afdc49a0c83290cf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function bench(f, Nrepition, label)
	local tSt=tmr.now()
	for i = 1, Nrepition do
		f(i)
	end
	local tEnd=tmr.now()

	local tExec = (tEnd-tSt)/Nrepition
	print(string.format("%8.1f uS",tExec) .. "\t" .. label)
	return tExec
end

print("===== Execution time benchmark ======")

bench(function() end, 1000, "empty function")

bench(function() local t={}; t[2]=2 end, 10 , "empty table creation")
bench(function() local t={1}; t[2]=2 end, 10 , "table expand by 1 element")
bench(function() local t={1}; t[2]=2; t[3]=3 end, 10 , "table expand by 2 element")

bench(function() bit.rshift(4000000,1) end, 10 , "bit.rshift(4000000,1)")

-- 8560613 corresponds to R2 settings
bench(function(x) microwire_send_data( 8560613 ) end, 10, "microwire_send_data")
bench(function(x) lmx2487_need_update[3]=true; send_register_lmx2487(2) end, 10, "send_register_lmx2487")

bench(function() freq2regestersValues(6.834e9) end, 10 , "freq2regestersValues")

-- main time hog
set_lmx2487_board_to_default_state()
bench(function(x) FreqToSettings(6.834e9+x*1.234e7) end, 10, "FreqToSettings")
bench(function(x) setFreq(6.834e9+x*1.234e7) end, 10, "setFreq")