Skip to content

Gap: console.time/timeLog timer resolution — prints near-zero instead of real elapsed ms #155

@proggeramlug

Description

@proggeramlug

Summary

test_gap_console_methods.ts exercises console.time / console.timeLog / console.timeEnd. The elapsed value prints as 0.005ms / 0.010ms where Node reports 1.271ms / 2.517ms. The actual work between calls is a real setTimeout(resolve, N) so the correct elapsed should be at least the sleep duration.

Actual vs Expected (excerpt)

< timer1: 0.005ms            (perry)
> timer1: 1.271ms            (node)
< timer1: 0.010ms            (perry)
> timer1: 2.517ms            (node)

Scope

  • console.time(label) stores the start time at performance.now() precision
  • console.timeLog(label) / console.timeEnd(label) compute now - start and format to ms with 3 decimals
  • Perry's current impl appears to use a clock that either doesn't advance during the timer wait or uses the wrong monotonic source

Related: see #74 (Date.now not advancing during tight CPU loops — different root cause but similar symptom class).

Impact

One of six currently-failing gap tests (baseline 22/28). Likely 3-4 lines of runtime change in console.rs or builtins.rs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions