Skip to content

Commit

Permalink
Add benchmark for composer telemetry parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoebi committed Jan 5, 2024
1 parent b71c98e commit 25e2967
Show file tree
Hide file tree
Showing 7 changed files with 5,396 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ext/ddtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,10 @@ PHP_FUNCTION(dd_trace_internal_fn) {
} else if (FUNCTION_NAME_MATCHES("finalize_telemetry")) {
dd_finalize_telemtry();
RETVAL_TRUE;
} else if (params_count == 1 && FUNCTION_NAME_MATCHES("detect_composer_installed_json")) {
ddog_CharSlice path = dd_zend_string_to_CharSlice(Z_STR_P(ZVAL_VARARG_PARAM(params, 0)));
ddtrace_detect_composer_installed_json(&ddtrace_sidecar, ddtrace_sidecar_instance_id, &DDTRACE_G(telemetry_queue_id), path);
RETVAL_TRUE;
} else if (FUNCTION_NAME_MATCHES("synchronous_flush")) {
uint32_t timeout = 100;
if (params_count == 1) {
Expand Down
22 changes: 22 additions & 0 deletions tests/Benchmarks/API/ComposerTelemetryBench.php
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"
);
}
}
2 changes: 2 additions & 0 deletions tests/Benchmarks/reports/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Empty file removed tests/Benchmarks/reports/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions tests/Benchmarks/support/ComposerTelemetryBench/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return \time(); // Do not do _nothing_
Loading

0 comments on commit 25e2967

Please sign in to comment.