summaryrefslogtreecommitdiff
path: root/bench_lmx2487.lua
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-06-10 20:22:03 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-06-10 21:43:14 -0400
commit97ce2148eb3b65e4cfa69321497d8977f2e3cee6 (patch)
tree633a6bf74a837e3fe16b8b50469fa47e20a2074d /bench_lmx2487.lua
parent9fbe8efa063c5dcd379348ba5b4a858036c92978 (diff)
downloadnodeMCU_rf_source_lmx2487-97ce2148eb3b65e4cfa69321497d8977f2e3cee6.tar.gz
nodeMCU_rf_source_lmx2487-97ce2148eb3b65e4cfa69321497d8977f2e3cee6.zip
added benchmark file
Diffstat (limited to 'bench_lmx2487.lua')
-rw-r--r--bench_lmx2487.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/bench_lmx2487.lua b/bench_lmx2487.lua
new file mode 100644
index 0000000..a952305
--- /dev/null
+++ b/bench_lmx2487.lua
@@ -0,0 +1,48 @@
+function bench(f, Nrepition, label)
+ local tSt=tmr.now()
+ for i = 1, Nrepition do
+ f()
+ 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)")
+
+bench(function() local tB=toBits(4000000) end, 10 , "toBits(4000000)")
+
+tB=toBits(4000000)
+bench(function() local d=toNum(tB) end, 10 , "toNum")
+tB=nil
+
+bench(function() freq2regestersValues(6.834e9) end, 10 , "freq2regestersValues")
+
+sinit= initSettings()
+bench(function() local sTmp=copySettings(sinit) end, 10 , "copySettings")
+sinit=nil
+
+tB=toBits(4000000)
+bench(function() pad2NumBitsInPlace(tB,22) end, 10 , "pad2NumBitsInPlace")
+tB=nil
+
+tB=toBits(4000000)
+tB=pad2NumBitsInPlace(tB,22)
+bench(function() local tTmp=bitSlice(tB,13,22) end, 10 , "bitSlice")
+tB=nil
+
+-- main time hog
+sinit= initSettings()
+bench(function() snew = FreqToSettings(6.834e9, sinit) end, 1, "FreqToSettings")
+sinit=nil
+