Skip to content

Improve timer's performance #4

@Yuyz0112

Description

@Yuyz0112

We are using requestAnimationFrame to perform a more accurate timer than setTimeout.
Currently, we init a timer for every recorded event, which means there are multiple requestAnimationFrame checks at the same time.

According to the spec, the callbacks of RAF are stored in a list and executed in order, so multiple RAF should have no main difference to one.
But this benchmark shows the multiple ones was much slower.

Maybe we should also implement a callback list with an optimized data structure, which sorted the callbacks by its timestamp.
For example:

[
  { cb: fn1, timestamp: t1 },
  { cb: fn2, timestamp: t2 },
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions