From 3f3103fa8add1d512c008822898f019fea496ed2 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Mon, 23 Jun 2014 16:45:23 +0200 Subject: [PATCH 1/2] nfv: Print bits-per-second (Goodput) and support NFV_PROF. --- src/designs/nfv/nfv | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/designs/nfv/nfv b/src/designs/nfv/nfv index 80142a488a..6991dde8d8 100755 --- a/src/designs/nfv/nfv +++ b/src/designs/nfv/nfv @@ -50,12 +50,19 @@ function run (npackets) else npackets = tonumber(npackets) print(app.app_table.vm.input.rx.stats.rxpackets) - local start, packets = 0, 0 + local start, packets, bytes = 0, 0, 0 local done = function () if start == 0 and app.app_table.vm.input.rx.stats.rxpackets > 0 then -- started receiving, record time and packet count packets = app.app_table.vm.input.rx.stats.rxpackets + bytes = app.app_table.vm.input.rx.stats.rxbytes start = C.get_monotonic_time() + if os.getenv("NFV_PROF") then + require("jit.p").start(os.getenv("NFV_PROF")) + main.profiling = true + else + print("No LuaJIT profiling enabled ($NFV_PROF unset).") + end end return app.app_table.vm.input.rx.stats.rxpackets - packets >= npackets end @@ -65,9 +72,10 @@ function run (npackets) local runtime = finish - start packets = app.app_table.vm.input.rx.stats.rxpackets - packets + bytes = app.app_table.vm.input.rx.stats.rxbytes - bytes engine.report() print() - print(("Processed %.1f million packets in %.2f seconds"):format(packets / 1e6, runtime)) + print(("Processed %.1f million packets in %.2f seconds (%d bytes; %.2f Gbps)"):format(packets / 1e6, runtime, bytes, bytes * 8.0 / 1e9 / runtime)) print(("Made %s breaths: %.2f packets per breath; %.2fus per breath"):format(lib.comma_value(engine.breaths), packets / engine.breaths, runtime / engine.breaths * 1e6)) print(("Rate(Mpps):\t%.3f"):format(packets / runtime / 1e6)) end From beab9e399c5200d3d053a22d24783a69036785a4 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Tue, 24 Jun 2014 13:12:09 +0200 Subject: [PATCH 2/2] main.profiling and main.debug_on_error not local anymore. So that it's possible to set them from outside. --- src/core/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/main.lua b/src/core/main.lua index 5c22b845ff..a7b756ca0e 100644 --- a/src/core/main.lua +++ b/src/core/main.lua @@ -35,8 +35,8 @@ Available options are: -jp=args[,.output] ]] -local debug_on_error = false -local profiling = false +debug_on_error = false +profiling = false -- List of parameters passed on the command line. parameters = {}