Module: CMDx::Middlewares::Runtime
Overview
Middleware for measuring task execution runtime.
The Runtime middleware provides performance monitoring by measuring the execution time of tasks using monotonic clock for accuracy. It stores runtime measurements in task result metadata for analysis.
Instance Method Summary collapse
-
#call(task, **options) { ... } ⇒ Object
Middleware entry point that measures task execution runtime and task execution start and end times.
Instance Method Details
#call(task, **options) { ... } ⇒ Object
Middleware entry point that measures task execution runtime and task execution start and end times.
Evaluates the condition from options and measures execution time if enabled. Uses monotonic clock for precise timing measurements and stores the result in task metadata.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cmdx/middlewares/runtime.rb', line 38 def call(task, **) unow = utc_time mnow = monotonic_time return yield unless Utils::Condition.evaluate(task, ) result = yield task.result..merge!( runtime: monotonic_time - mnow, ended_at: utc_time, started_at: unow ) result end |