Skip to content

Commit

Permalink
Merge 6c5407e into bf33456
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Dec 12, 2019
2 parents bf33456 + 6c5407e commit 9f94982
Show file tree
Hide file tree
Showing 13 changed files with 1,044 additions and 676 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
.php_cs.cache
.phpunit.result.cache
build
composer.lock
coverage
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -3,11 +3,10 @@ sudo: false
language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4snapshot
- 7.4
- nightly

matrix:
Expand Down
11 changes: 3 additions & 8 deletions composer.json
Expand Up @@ -26,12 +26,12 @@
}
],
"require": {
"php": ">=7"
"php": ">=7.1"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"http2jp/hpack-test-case": "^1",
"phpunit/phpunit": "^6"
"phpunit/phpunit": "^6 | ^7"
},
"autoload": {
"psr-4": {
Expand All @@ -40,12 +40,7 @@
},
"autoload-dev": {
"psr-4": {
"Amp\\Http\\HPack\\Test\\": "test"
}
},
"config": {
"platform": {
"php": "7.0.13"
"Amp\\Http\\": "test"
}
},
"repositories": [
Expand Down
19 changes: 15 additions & 4 deletions examples/bench.php
Expand Up @@ -24,19 +24,30 @@
}

$minDuration = \PHP_INT_MAX;
$minOps = \PHP_INT_MAX;

for ($i = 0; $i < 10; $i++) {
$start = \microtime(true);
$ops = 0;

foreach ($tests as $test) {
$hpack = new Amp\Http\HPack;
foreach ($cases as list($input, $output)) {
$hpack->decode($input, 8192);
$hpack = new Amp\Http\Internal\HPackNative;
foreach ($cases as [$input, $output]) {
$headers = $hpack->decode($input, 4096);
$hpack->encode($headers);

if ($headers !== $output) {
print 'Invalid headers' . \PHP_EOL;
exit(1);
}

$ops++;
}
}

$duration = \microtime(true) - $start;
$minDuration = \min($minDuration, $duration);
$minOps = \min($ops, $minOps);
}

print "$minDuration s" . PHP_EOL . PHP_EOL;
print "$minOps in $minDuration seconds" . \PHP_EOL;
22 changes: 6 additions & 16 deletions phpunit.xml.dist
@@ -1,21 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.7/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.0/phpunit.xsd"
bootstrap="vendor/autoload.php" colors="true">
<php>
<!-- Needed because @dataProvider uses iterator_to_array() -->
<ini name="memory_limit" value="1G" />
<ini name="error_reporting" value="-1" />
<ini name="memory_limit" value="1G"/>
<ini name="error_reporting" value="-1"/>
</php>
<testsuites>
<testsuite name="Amp HPack Test">
Expand All @@ -28,7 +18,7 @@
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage" title="Amp" highlight="true"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>

0 comments on commit 9f94982

Please sign in to comment.