Skip to content

Commit

Permalink
Merge pull request #212 from lukego/nfv-prof
Browse files Browse the repository at this point in the history
Added NFV_PROF option to nfv design: enables LuaJIT profiling after traffic starts to flow.
  • Loading branch information
lukego committed Jun 24, 2014
2 parents 4f050e0 + beab9e3 commit f774780
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/core/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
12 changes: 10 additions & 2 deletions src/designs/nfv/nfv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f774780

Please sign in to comment.