Skip to content

Commit 05fb30d

Browse files
committed
Improve global functions DX
1 parent b2ce594 commit 05fb30d

24 files changed

Lines changed: 985 additions & 1115 deletions

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ All Notable changes to `bakame/stackwatch` will be documented in this file.
1111
- Added `ViewExporter` and `Renderer` to allow viewing the log in browser or in the CLI
1212
- Added `dump()` and `dd()` methods to `Profiler`, `Timeline`, `SpanAggregator`, `Snapshot`, `Metrics`, `Span`, `Report`
1313
- Added `Metrics::sum`, `Metrics::range`,`Metrics::minimum`,`Metrics::maximun`,`Metrics::median`, `Metrics::aggregate`
14-
- Adding the `AggregationType` Enum to improve `Profiler::metrics`, the `Profile` Attribute and the `Metrics` usage.
14+
- Adding the `AggregatorType` Enum to improve `Stack::metrics`, the `Profile` Attribute and the `Metrics` usage.
1515
- **BC BREAK:** `Summary` is renamed `Span`.
1616
- `CallLocation` class to allow recording where the package `Snapshot` was called from [#8](https://github.com/bakame-php/stackwatch/pull/8)
1717
- `CallRange` class to allow manipulating location range within the `Summary` class.
@@ -32,7 +32,7 @@ All Notable changes to `bakame/stackwatch` will be documented in this file.
3232
- Added `toHuman()` method to return a human-readable version of `toArray`
3333
- Added `human()` method to return the human-redable version of a single property.
3434
- Added Snapshot relation method `compareTo` and its aliases `isBefore*` `isAfter*` and `isAtSameTime` using the `Snapshot::hrtime` property
35-
- **BC BREAK:** `Profiler` class is split into two classes `Profiler` and `SpanAggregator`
35+
- **BC BREAK:** `Profiler` class is split into two classes `Stack` and `Profiler`
3636

3737
### Fixed
3838

docs/1.0/exporters.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The package can help with exporting its metrics using different mechanisms.
99

1010
## JSON
1111

12-
Both the `SpanAggregator` and `Timeline` classes support JSON export via PHP's `json_encode` function.
12+
Both the `Profiler` and `Timeline` classes support JSON export via PHP's `json_encode` function.
1313
This allows you to serialize profiling data for inspection, storage, or transmission.
1414

1515
Calling `json_encode($profiler)` will produce a JSON object containing:
@@ -45,9 +45,9 @@ streams, string path and `SplFileInfo` objects.
4545

4646
```php
4747
use Bakame\Stackwatch\JsonExporter;
48-
use Bakame\Stackwatch\Profiler;
48+
use Bakame\Stackwatch\Stack;
4949

50-
$report = Profiler::report($service->calculateHeavyStuff(...), 500);
50+
$report = Stack::report($service->calculateHeavyStuff(...), 500);
5151
$exporter = new JsonExporter('path/to/store/the/profile.json', JSON_PRETTY_PRINT|JSON_BIGINT_AS_STRING);
5252
$exporter->exportReport($report);
5353
```
@@ -60,10 +60,10 @@ and only the last export will be stored. To get the data appended provide an alr
6060

6161
## CLI
6262

63-
You can display the `SpanAggregator` or the `Timeline` recorded data recorded using the `StatsExporter` class.
63+
You can display the `Profiler` or the `Timeline` recorded data recorded using the `StatsExporter` class.
6464

6565
```php
66-
use Bakame\Stackwatch\SpanAggregator;
66+
use Bakame\Stackwatch\Profiler;
6767
use Bakame\Stackwatch\ViewExporter;
6868

6969
$callback = function (int ...$args): int {
@@ -72,13 +72,13 @@ $callback = function (int ...$args): int {
7272
return array_sum($args);
7373
};
7474

75-
$aggregator = new SpanAggregator($callback);
75+
$aggregator = new Profiler($callback);
7676
$aggregator->profile('first_run', 1, 2);
7777
$aggregator->profile('last_run', 1, 2);
7878
$aggregator->run(1, 2);
7979

8080
$exporter = new ViewExporter();
81-
$exporter->exportSpanAggregator($aggregator);
81+
$exporter->exportProfiler($aggregator);
8282
```
8383
the following table will be outputted in your terminal.
8484

0 commit comments

Comments
 (0)