-
-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize the constructor of the
Span
class and add some benchmarks (#…
- Loading branch information
Showing
7 changed files
with
78 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package.xml | |
/vendor | ||
.idea | ||
.php-cs-fixer.cache | ||
.phpbench | ||
.phpunit.result.cache | ||
docs/_build | ||
tests/clover.xml |
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,6 @@ | ||
{ | ||
"$schema":"./vendor/phpbench/phpbench/phpbench.schema.json", | ||
"runner.bootstrap": "vendor/autoload.php", | ||
"runner.retry_threshold": 2, | ||
"runner.path": "tests/Benchmark" | ||
} |
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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sentry\Tests\Benchmark; | ||
|
||
use PhpBench\Benchmark\Metadata\Annotations\Iterations; | ||
use PhpBench\Benchmark\Metadata\Annotations\Revs; | ||
use Sentry\Tracing\Span; | ||
use Sentry\Tracing\TransactionContext; | ||
|
||
final class SpanBench | ||
{ | ||
/** | ||
* @var TransactionContext | ||
*/ | ||
private $context; | ||
|
||
/** | ||
* @var TransactionContext | ||
*/ | ||
private $contextWithTimestamp; | ||
|
||
public function __construct() | ||
{ | ||
$this->context = TransactionContext::fromSentryTrace('566e3688a61d4bc888951642d6f14a19-566e3688a61d4bc8-0'); | ||
$this->contextWithTimestamp = TransactionContext::fromSentryTrace('566e3688a61d4bc888951642d6f14a19-566e3688a61d4bc8-0'); | ||
$this->contextWithTimestamp->setStartTimestamp(microtime(true)); | ||
} | ||
|
||
/** | ||
* @Revs(100000) | ||
* @Iterations(10) | ||
*/ | ||
public function benchConstructor(): void | ||
{ | ||
$span = new Span(); | ||
} | ||
|
||
/** | ||
* @Revs(100000) | ||
* @Iterations(10) | ||
*/ | ||
public function benchConstructorWithInjectedContext(): void | ||
{ | ||
$span = new Span($this->context); | ||
} | ||
|
||
/** | ||
* @Revs(100000) | ||
* @Iterations(10) | ||
*/ | ||
public function benchConstructorWithInjectedContextAndStartTimestamp(): void | ||
{ | ||
$span = new Span($this->contextWithTimestamp); | ||
} | ||
} |