Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DX][Stopwatch] Assign colors to custom categories #33514

Closed
@javiereguiluz

Description

@javiereguiluz

Description
I'm playing with the Stopwatch component and I used something like this:

$this->stopwatch->start('export-data', 'export');

In the profiler I can see this ... but the export custom category is not assigned a color, so it looks like a bug and it complicates understanding the different events:

image

Proposed solution
Let's assign a different color for each custom category.

In practice:

  1. We select 5 to 10 beautiful colors which are not already associated with Symfony things (the event's blue, the doctrine's orange, the twig's green, etc.)
  2. We assign a color randomly to each custom category.

Instead of pure randomness, we could apply the same strategy of the Asset component, which uses this code to always assign the same base URL for each path. This way we'd always select the same "random" color for the same category name:

protected function chooseBaseUrl($path)
{
    return (int) fmod(hexdec(substr(hash('sha256', $path), 0, 10)), \count($this->baseUrls));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)FeatureStopwatch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions