Skip to content

Commit f845364

Browse files
committed
do the flush logic in EmitEvent so that trace recording and profiling can be done separately
1 parent ef00f26 commit f845364

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

test/helpers/jit_profiler.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ function Profiler:EmitEvent(event--[[#: TEvent]])
256256
local idx = self.event_count + 1
257257
self.events[idx] = event
258258
self.event_count = idx
259+
260+
if event.time - self.last_flush_time >= self.flush_interval then
261+
self.last_flush_time = event.time
262+
self:Save()
263+
end
259264
end
260265

261266
-- --- Section tracking ---
@@ -447,7 +452,7 @@ do
447452
-- Event accumulation
448453
self.events = {}
449454
self.event_count = 0
450-
self.last_flush_time = 0
455+
self.last_flush_time = self.time_start
451456
-- String interning
452457
self.strings = {}
453458
self.string_lookup = {}
@@ -525,12 +530,6 @@ do
525530
vm_state = vmstate,
526531
section_path = self.section_path,
527532
}
528-
local now = self.get_time()
529-
530-
if now - self.last_flush_time >= self.flush_interval then
531-
self.last_flush_time = now
532-
self:Save()
533-
end
534533
end)
535534
end
536535

0 commit comments

Comments
 (0)