-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic PHP MicroBenchmarks (#2435)
* Add foundation files * (WIP) Handle environment reloads * fix: Exclude hook after class binding * fix: Benchmark bootstrapping & Fatal Errors * Add PDO, Laravel, Symfony, & WordPress Benchmarks * Add `benchmarks_opcache` * Add trace flush & serialization benchmarks * Send traces (if any) through sidecar * Add SamplingRuleMatchingBench, TraceAnnotationsBench, & PHPRedisBench * Run `benchmarks` & `benchmarks_opcache` * Change report to `default` * Increase RetryThreshold to 10 * Fix HookBench's hook * Refactor & Remove Dead Code * Add MessagePackSerializationBench * Update README.md * Move `phpbench/phpbench` to the `benchmarks` scenario * Use Symfony v5.2 in SymfonyBench.php * Add README.md * Modify MessagePackSerializationBench.php & TraceAnnotationsBench.php to be coherent * Consider a `profiler` and `tracer` scenario * Compare the different hooking functions * typo: `PHPBENCH_OPCACHE_CONFIG` * fix: Update benchmark dependencies (Symfony & Laravel) * bench: Empty `index.php` web requests overhead * Add benchmark for composer telemetry parsing --------- Co-authored-by: Bob Weinand <bob.weinand@datadoghq.com>
- Loading branch information
Showing
35 changed files
with
6,897 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Benchmarks\API; | ||
|
||
class ComposerTelemetryBench | ||
{ | ||
/** | ||
* @Revs(1) | ||
* @Iterations(10) | ||
* @OutputTimeUnit("microseconds") | ||
* @RetryThreshold(10.0) | ||
*/ | ||
public function benchTelemetryParsing() | ||
{ | ||
dd_trace_internal_fn( | ||
"detect_composer_installed_json", | ||
__DIR__ . "/../support/ComposerTelemetryBench/vendor/autoload.php" | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Benchmarks\API; | ||
|
||
class ContextPropagationBench | ||
{ | ||
public static $traceContext128Bit = [ | ||
'traceparent' => '00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01', | ||
'tracestate' => 'rojo=00f067aa0ba902b7,dd=t.dm:-1;t.congo:t61rcWkgMzE' | ||
]; | ||
|
||
public static $traceContext64Bit = [ | ||
'traceparent' => '00-0000000000000000sc151df7d6ee5e2d6-a3978fb9b92502a8-01', | ||
'tracestate' => 'rojo=00f067aa0ba902b7,dd=t.dm:-1;t.congo:t61rcWkgMzE' | ||
]; | ||
|
||
public static $headers128Bit = [ | ||
'x-datadog-trace-id' => '0af7651916cd43dd8448eb211c80319c', | ||
'x-datadog-parent-id' => 'b7ad6b7169203331', | ||
'x-datadog-sampling-priority' => 3, | ||
'x-datadog-origin' => 'datadog' | ||
]; | ||
|
||
public static $headers64Bit = [ | ||
"x-datadog-trace-id" => 42, | ||
"x-datadog-parent-id" => 10, | ||
"x-datadog-origin" => "datadog", | ||
"x-datadog-sampling-priority" => 3, | ||
]; | ||
|
||
/** | ||
* @Revs(1) | ||
* @Iterations(10) | ||
* @OutputTimeUnit("microseconds") | ||
* @RetryThreshold(10.0) | ||
* @BeforeMethods("resetContext") | ||
*/ | ||
public function benchExtractTraceContext128Bit() | ||
{ | ||
\DDTrace\consume_distributed_tracing_headers(self::$traceContext128Bit); | ||
} | ||
|
||
/** | ||
* @Revs(1) | ||
* @Iterations(10) | ||
* @OutputTimeUnit("microseconds") | ||
* @RetryThreshold(10.0) | ||
* @BeforeMethods("resetContext") | ||
*/ | ||
public function benchExtractTraceContext64Bit() | ||
{ | ||
\DDTrace\consume_distributed_tracing_headers(self::$traceContext64Bit); | ||
} | ||
|
||
/** | ||
* @Revs(1) | ||
* @Iterations(10) | ||
* @OutputTimeUnit("microseconds") | ||
* @RetryThreshold(10.0) | ||
* @BeforeMethods("resetContext") | ||
*/ | ||
public function benchExtractHeaders128Bit() | ||
{ | ||
\DDTrace\consume_distributed_tracing_headers(self::$headers128Bit); | ||
} | ||
|
||
/** | ||
* @Revs(1) | ||
* @Iterations(10) | ||
* @OutputTimeUnit("microseconds") | ||
* @RetryThreshold(10.0) | ||
* @BeforeMethods("resetContext") | ||
*/ | ||
public function benchExtractHeaders64Bit() | ||
{ | ||
\DDTrace\consume_distributed_tracing_headers(self::$headers64Bit); | ||
} | ||
|
||
/** | ||
* @Revs(1) | ||
* @Iterations(10) | ||
* @OutputTimeUnit("microseconds") | ||
* @RetryThreshold(10.0) | ||
* @BeforeMethods("setUp128BitContext") | ||
*/ | ||
public function benchInject128Bit() | ||
{ | ||
\DDTrace\generate_distributed_tracing_headers(); | ||
} | ||
|
||
/** | ||
* @Revs(1) | ||
* @Iterations(10) | ||
* @OutputTimeUnit("microseconds") | ||
* @RetryThreshold(10.0) | ||
* @BeforeMethods("setUp64BitContext") | ||
*/ | ||
public function benchInject64Bit() | ||
{ | ||
\DDTrace\generate_distributed_tracing_headers(); | ||
} | ||
|
||
public function setUp128BitContext() | ||
{ | ||
$this->resetContext(); | ||
\DDTrace\consume_distributed_tracing_headers(self::$traceContext128Bit); | ||
} | ||
|
||
public function setUp64BitContext() | ||
{ | ||
$this->resetContext(); | ||
\DDTrace\consume_distributed_tracing_headers(self::$traceContext64Bit); | ||
} | ||
|
||
public function resetContext() | ||
{ | ||
\DDTrace\set_distributed_tracing_context("0", "0"); | ||
} | ||
} |
Oops, something went wrong.