Created
April 27, 2024 08:35
-
-
Save ochaton/e4e91d07f069ccd85ef280fdb85188ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local fiber = require 'fiber' | |
local clock = require 'clock' | |
local fun = require 'fun' | |
require 'jit'.on() | |
fiber.top_enable() | |
local COLLECT_INTERVAL = 1 | |
fiber.create(function() | |
fiber.name("monitor") | |
fiber.yield() | |
local prev = {} | |
local tx_time = clock.thread() | |
while true do | |
local cpu = fiber.top().cpu | |
local info = fiber.info({ bt = false }) | |
local fids = fun.totable(info) | |
table.sort(fids) | |
print("------------------------------------------------------") | |
local run_diff = 0 | |
-- collect sched | |
if prev[1] then | |
local diff = cpu['1/sched'].time - prev[1] | |
print(1, "sched", 1000*diff) | |
run_diff = run_diff + diff | |
prev[1] = cpu['1/sched'].time | |
end | |
prev[1] = cpu['1/sched'].time | |
for _, fid in ipairs(fids) do | |
local finfo = info[fid] | |
local cpu_time = cpu[fid..'/'..finfo.name] | |
cpu_time = cpu_time and cpu_time.time or finfo.time | |
if prev[fid] then | |
local diff = cpu_time - prev[fid] | |
run_diff = run_diff + diff | |
print(fid, finfo.name, 1000*diff) | |
end | |
prev[fid] = cpu_time | |
end | |
local current_tx = clock.thread() | |
print("tx ", "tx", 1000*(current_tx-tx_time)) | |
print("diff", "diff", 1000*run_diff) | |
tx_time = current_tx | |
fiber.sleep(COLLECT_INTERVAL) | |
end | |
end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------ | |
1 sched 0.140917 | |
101 lua 0 | |
102 on_shutdown 0 | |
104 monitor 0.141165 | |
tx tx 5.803333 | |
diff diff 0.282082 | |
------------------------------------------------------ | |
1 sched 0.122536 | |
101 lua 0 | |
102 on_shutdown 0 | |
104 monitor 0.283506 | |
tx tx 4.337542 | |
diff diff 0.406042 | |
------------------------------------------------------ | |
1 sched 0.122907 | |
101 lua 0 | |
102 on_shutdown 0 | |
104 monitor 0.088674 | |
tx tx 5.346792 | |
diff diff 0.211581 | |
------------------------------------------------------ | |
1 sched 0.06869 | |
101 lua 0 | |
102 on_shutdown 0 | |
104 monitor 0.10689 | |
tx tx 2.858416 | |
diff diff 0.17558 | |
------------------------------------------------------ | |
1 sched 0.075669 | |
101 lua 0 | |
102 on_shutdown 0 | |
104 monitor 0.146545 | |
tx tx 2.934209 | |
diff diff 0.222214 | |
------------------------------------------------------ | |
1 sched 0.072609999999999 | |
101 lua 0 | |
102 on_shutdown 0 | |
104 monitor 0.120014 | |
tx tx 2.692958 | |
diff diff 0.192624 | |
------------------------------------------------------ | |
1 sched 0.070706 | |
101 lua 0 | |
102 on_shutdown 0 | |
104 monitor 0.066752999999999 | |
tx tx 2.690458 | |
diff diff 0.137459 | |
------------------------------------------------------ | |
1 sched 0.077798 | |
101 lua 0 | |
102 on_shutdown 0 | |
104 monitor 0.185081 | |
tx tx 2.880042 | |
diff diff 0.262879 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment