Skip to content

Add a built-in runtime profiler #72

Description

@TrixNEW

Summary

zphp should include a profiler for finding expensive PHP code and runtime bottlenecks.

For example:

zphp profile app.php

or:

zphp profile serve app.php

Useful metrics

Track:

  • function execution time
  • call counts
  • self time vs total time
  • allocations
  • allocated bytes
  • peak memory
  • GC activity
  • VM/opcode execution
  • blocking I/O time
  • worker/thread usage
  • Fiber scheduling time

Example output:

Function                 Calls     Self       Total
World::tick               2000     420ms      780ms
encodeChunk                800     300ms      310ms
Player::tick             50000     250ms      400ms

Optional output formats could include:

  • text
  • JSON
  • Chrome Trace
  • flamegraph-compatible data

Profiling should have minimal overhead when disabled.


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions