Skip to content

Commit 93823b9

Browse files
authored
PHPBench (#20)
1 parent 097ba7b commit 93823b9

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

.github/workflows/main.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,28 @@ jobs:
2121
php-version: '8.0'
2222
tools: cs2pr, phpcs
2323
- name: Run phpcs
24-
run: phpcs -q --report=checkstyle src/*.php tests/*.php | cs2pr
24+
run: phpcs -q --report=checkstyle src/ tests/ | cs2pr
2525

26+
benchmark:
27+
runs-on: ubuntu-20.04
28+
strategy:
29+
matrix:
30+
php-versions: ['7.4', '8.0', '8.1']
31+
steps:
32+
- uses: actions/checkout@v2.4.0
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@2.15.0
35+
with:
36+
php-version: ${{ matrix.php-versions }}
37+
tools: composer, phpbench/phpbench
38+
coverage: none
39+
ini-values: memory_limit=-1
40+
- name: Install dependencies
41+
run: composer install
42+
- name: PHPBench
43+
run: phpbench run -q --report=aggregate --
44+
45+
2646
unit-tests:
2747
runs-on: ubuntu-20.04
2848
strategy:

phpbench.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"runner.bootstrap": "vendor/autoload.php",
3+
"runner.path": "tests/Benchmark",
4+
"runner.iterations": 5,
5+
"runner.revs": 1000
6+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace UUID\Benchmark;
6+
7+
use UUID\UUID;
8+
9+
class UUIDGenerationBench
10+
{
11+
public function benchUUID3Generation(): void
12+
{
13+
UUID::uuid3(UUID::NAMESPACE_DNS, 'php.net');
14+
}
15+
16+
public function benchUUID4Generation(): void
17+
{
18+
UUID::uuid4();
19+
}
20+
21+
public function benchUUID5Generation(): void
22+
{
23+
UUID::uuid5(UUID::NAMESPACE_DNS, 'php.net');
24+
}
25+
26+
public function benchUUID6Generation(): void
27+
{
28+
UUID::uuid6();
29+
}
30+
}

0 commit comments

Comments
 (0)