Skip to content

endTime

reference
1 min readUpdated

Kind: Function

Source: src/middleware/timing/timing.ts

Part of: Middleware

End a timer for the timing middleware.

endTime stops the timer managed by the timing middleware when request processing finishes. It pairs with the middleware’s timer start logic to calculate and record timing data for the completed request.

Signature

ts
function endTime(c: Context, name: string, precision: number)

Parameters

NameType
cContext
namestring
precisionnumber

Diagram

mermaid
graph LR
  Request[Incoming request] --> Start[Start timing middleware]
  Start --> Handler[Request handler]
  Handler --> End[endTime]
  End --> Timing[Elapsed timing data]
  Timing --> Response[Completed response]

Usage

ts
import { endTime } from './middleware/timing/timing';

// Call after the request handler has completed and the timer state exists.
function onRequestComplete(request: Request, response: Response) {
  endTime(request, response);
}

AI Coding Instructions

  • Call endTime only after the timing middleware has initialized timer state for the request.
  • Keep timer start and end handling within the same request lifecycle.
  • Preserve any request or response fields used to store timing data.
  • Invoke the function from response completion or middleware flow rather than before handler work has finished.

Was this page helpful?

Download as PDF
endTime — Hono (narrator proof)