Skip to content

Instantly share code, notes, and snippets.

@uzulla
Created January 5, 2021 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uzulla/fdb0d4312cb90a999f8424f128477b29 to your computer and use it in GitHub Desktop.
Save uzulla/fdb0d4312cb90a999f8424f128477b29 to your computer and use it in GitHub Desktop.
some amphp bench code
{
"require": {
"amphp/amp": "^2.5",
"amphp/dns": "^1.2",
"amphp/http-client": "^4.5"
}
}
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "159f9881c36c38c61c453c904e99ab56",
"packages": [
{
"name": "amphp/amp",
"version": "v2.5.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/amp.git",
"reference": "f220a51458bf4dd0dedebb171ac3457813c72bbc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/amp/zipball/f220a51458bf4dd0dedebb171ac3457813c72bbc",
"reference": "f220a51458bf4dd0dedebb171ac3457813c72bbc",
"shasum": ""
},
"require": {
"php": ">=7"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1",
"ext-json": "*",
"jetbrains/phpstorm-stubs": "^2019.3",
"phpunit/phpunit": "^6.0.9 | ^7",
"psalm/phar": "^3.11@dev",
"react/promise": "^2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Amp\\": "lib"
},
"files": [
"lib/functions.php",
"lib/Internal/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Lowrey",
"email": "rdlowrey@php.net"
},
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
},
{
"name": "Bob Weinand",
"email": "bobwei9@hotmail.com"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
}
],
"description": "A non-blocking concurrency framework for PHP applications.",
"homepage": "http://amphp.org/amp",
"keywords": [
"async",
"asynchronous",
"awaitable",
"concurrency",
"event",
"event-loop",
"future",
"non-blocking",
"promise"
],
"funding": [
{
"url": "https://github.com/amphp",
"type": "github"
}
],
"time": "2020-07-14T21:47:18+00:00"
},
{
"name": "amphp/byte-stream",
"version": "v1.8.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/byte-stream.git",
"reference": "f0c20cf598a958ba2aa8c6e5a71c697d652c7088"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/byte-stream/zipball/f0c20cf598a958ba2aa8c6e5a71c697d652c7088",
"reference": "f0c20cf598a958ba2aa8c6e5a71c697d652c7088",
"shasum": ""
},
"require": {
"amphp/amp": "^2",
"php": ">=7.1"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1.4",
"friendsofphp/php-cs-fixer": "^2.3",
"jetbrains/phpstorm-stubs": "^2019.3",
"phpunit/phpunit": "^6 || ^7 || ^8",
"psalm/phar": "^3.11.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Amp\\ByteStream\\": "lib"
},
"files": [
"lib/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
}
],
"description": "A stream abstraction to make working with non-blocking I/O simple.",
"homepage": "http://amphp.org/byte-stream",
"keywords": [
"amp",
"amphp",
"async",
"io",
"non-blocking",
"stream"
],
"time": "2020-06-29T18:35:05+00:00"
},
{
"name": "amphp/cache",
"version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/cache.git",
"reference": "e7bccc526fc2a555d59e6ee8380eeb39a95c0835"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/cache/zipball/e7bccc526fc2a555d59e6ee8380eeb39a95c0835",
"reference": "e7bccc526fc2a555d59e6ee8380eeb39a95c0835",
"shasum": ""
},
"require": {
"amphp/amp": "^2",
"amphp/serialization": "^1",
"amphp/sync": "^1.2",
"php": ">=7.1"
},
"conflict": {
"amphp/file": "<0.2 || >=2"
},
"require-dev": {
"amphp/file": "^1",
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1.1",
"phpunit/phpunit": "^6 | ^7 | ^8 | ^9",
"vimeo/psalm": "^3.11@dev"
},
"type": "library",
"autoload": {
"psr-4": {
"Amp\\Cache\\": "lib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
},
{
"name": "Daniel Lowrey",
"email": "rdlowrey@php.net"
}
],
"description": "A promise-aware caching API for Amp.",
"homepage": "https://github.com/amphp/cache",
"time": "2020-04-19T16:10:08+00:00"
},
{
"name": "amphp/dns",
"version": "v1.2.3",
"source": {
"type": "git",
"url": "https://github.com/amphp/dns.git",
"reference": "852292532294d7972c729a96b49756d781f7c59d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/dns/zipball/852292532294d7972c729a96b49756d781f7c59d",
"reference": "852292532294d7972c729a96b49756d781f7c59d",
"shasum": ""
},
"require": {
"amphp/amp": "^2",
"amphp/byte-stream": "^1.1",
"amphp/cache": "^1.2",
"amphp/parser": "^1",
"amphp/windows-registry": "^0.3",
"daverandom/libdns": "^2.0.1",
"ext-filter": "*",
"ext-json": "*",
"php": ">=7.0"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1",
"phpunit/phpunit": "^6 || ^7 || ^8 || ^9"
},
"type": "library",
"autoload": {
"psr-4": {
"Amp\\Dns\\": "lib"
},
"files": [
"lib/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Chris Wright",
"email": "addr@daverandom.com"
},
{
"name": "Daniel Lowrey",
"email": "rdlowrey@php.net"
},
{
"name": "Bob Weinand",
"email": "bobwei9@hotmail.com"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
},
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
}
],
"description": "Async DNS resolution for Amp.",
"homepage": "https://github.com/amphp/dns",
"keywords": [
"amp",
"amphp",
"async",
"client",
"dns",
"resolve"
],
"funding": [
{
"url": "https://github.com/amphp",
"type": "github"
}
],
"time": "2020-07-21T19:04:57+00:00"
},
{
"name": "amphp/hpack",
"version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/hpack.git",
"reference": "0dcd35f9a8d9fc04d5fb8af0aeb109d4474cfad8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/hpack/zipball/0dcd35f9a8d9fc04d5fb8af0aeb109d4474cfad8",
"reference": "0dcd35f9a8d9fc04d5fb8af0aeb109d4474cfad8",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"http2jp/hpack-test-case": "^1",
"phpunit/phpunit": "^6 | ^7"
},
"type": "library",
"autoload": {
"psr-4": {
"Amp\\Http\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Lowrey",
"email": "rdlowrey@php.net"
},
{
"name": "Bob Weinand"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
},
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
}
],
"description": "HTTP/2 HPack implementation.",
"homepage": "https://github.com/amphp/hpack",
"keywords": [
"headers",
"hpack",
"http-2"
],
"time": "2020-01-11T19:33:14+00:00"
},
{
"name": "amphp/http",
"version": "v1.6.1",
"source": {
"type": "git",
"url": "https://github.com/amphp/http.git",
"reference": "dfd33554b82a7d8f18cced56352bcc8270318dfe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/http/zipball/dfd33554b82a7d8f18cced56352bcc8270318dfe",
"reference": "dfd33554b82a7d8f18cced56352bcc8270318dfe",
"shasum": ""
},
"require": {
"amphp/hpack": "^3",
"php": ">=7.1"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"phpunit/phpunit": "^7 || ^6.5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Amp\\Http\\": "src"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
}
],
"description": "Basic HTTP primitives which can be shared by servers and clients.",
"funding": [
{
"url": "https://github.com/amphp",
"type": "github"
}
],
"time": "2020-09-11T18:23:42+00:00"
},
{
"name": "amphp/http-client",
"version": "v4.5.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/http-client.git",
"reference": "39099a5ad69379eb90f2ca83c082b276539328b9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/http-client/zipball/39099a5ad69379eb90f2ca83c082b276539328b9",
"reference": "39099a5ad69379eb90f2ca83c082b276539328b9",
"shasum": ""
},
"require": {
"amphp/amp": "^2.4",
"amphp/byte-stream": "^1.6",
"amphp/hpack": "^3",
"amphp/http": "^1.6",
"amphp/socket": "^1",
"amphp/sync": "^1.3",
"league/uri": "^6",
"php": ">=7.2",
"psr/http-message": "^1"
},
"conflict": {
"amphp/file": "<0.2"
},
"require-dev": {
"amphp/file": "^1 || ^0.3 || ^0.2",
"amphp/http-server": "^2",
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1.1",
"amphp/react-adapter": "^2.1",
"clue/socks-react": "^1.0",
"ext-json": "*",
"kelunik/link-header-rfc5988": "^1.0",
"laminas/laminas-diactoros": "^2.3",
"phpunit/phpunit": "^7 || ^8 || ^9",
"vimeo/psalm": "^3.9@dev"
},
"suggest": {
"amphp/file": "Required for file request bodies and HTTP archive logging",
"ext-json": "Required for logging HTTP archives",
"ext-zlib": "Allows using compression for response bodies."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
}
},
"autoload": {
"psr-4": {
"Amp\\Http\\Client\\": "src"
},
"files": [
"src/Internal/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Lowrey",
"email": "rdlowrey@gmail.com"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
},
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
}
],
"description": "Asynchronous concurrent HTTP/2 and HTTP/1.1 client built on the Amp concurrency framework",
"homepage": "https://github.com/amphp/http-client",
"keywords": [
"async",
"client",
"concurrent",
"http",
"non-blocking",
"rest"
],
"funding": [
{
"url": "https://github.com/amphp",
"type": "github"
}
],
"time": "2020-07-21T19:18:31+00:00"
},
{
"name": "amphp/parser",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/parser.git",
"reference": "f83e68f03d5b8e8e0365b8792985a7f341c57ae1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/parser/zipball/f83e68f03d5b8e8e0365b8792985a7f341c57ae1",
"reference": "f83e68f03d5b8e8e0365b8792985a7f341c57ae1",
"shasum": ""
},
"require": {
"php": ">=7"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.3",
"phpunit/phpunit": "^6"
},
"type": "library",
"autoload": {
"psr-4": {
"Amp\\Parser\\": "lib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
},
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
}
],
"description": "A generator parser to make streaming parsers simple.",
"homepage": "https://github.com/amphp/parser",
"keywords": [
"async",
"non-blocking",
"parser",
"stream"
],
"time": "2017-06-06T05:29:10+00:00"
},
{
"name": "amphp/process",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/process.git",
"reference": "355b1e561b01c16ab3d78fada1ad47ccc96df70e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/process/zipball/355b1e561b01c16ab3d78fada1ad47ccc96df70e",
"reference": "355b1e561b01c16ab3d78fada1ad47ccc96df70e",
"shasum": ""
},
"require": {
"amphp/amp": "^2",
"amphp/byte-stream": "^1.4",
"php": ">=7"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1",
"phpunit/phpunit": "^6"
},
"type": "library",
"autoload": {
"psr-4": {
"Amp\\Process\\": "lib"
},
"files": [
"lib/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bob Weinand",
"email": "bobwei9@hotmail.com"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
},
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
}
],
"description": "Asynchronous process manager.",
"homepage": "https://github.com/amphp/process",
"time": "2019-02-26T16:33:03+00:00"
},
{
"name": "amphp/serialization",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/serialization.git",
"reference": "693e77b2fb0b266c3c7d622317f881de44ae94a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/serialization/zipball/693e77b2fb0b266c3c7d622317f881de44ae94a1",
"reference": "693e77b2fb0b266c3c7d622317f881de44ae94a1",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"phpunit/phpunit": "^9 || ^8 || ^7"
},
"type": "library",
"autoload": {
"psr-4": {
"Amp\\Serialization\\": "src"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
}
],
"description": "Serialization tools for IPC and data storage in PHP.",
"homepage": "https://github.com/amphp/serialization",
"keywords": [
"async",
"asynchronous",
"serialization",
"serialize"
],
"time": "2020-03-25T21:39:07+00:00"
},
{
"name": "amphp/socket",
"version": "v1.1.3",
"source": {
"type": "git",
"url": "https://github.com/amphp/socket.git",
"reference": "b9064b98742d12f8f438eaf73369bdd7d8446331"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/socket/zipball/b9064b98742d12f8f438eaf73369bdd7d8446331",
"reference": "b9064b98742d12f8f438eaf73369bdd7d8446331",
"shasum": ""
},
"require": {
"amphp/amp": "^2",
"amphp/byte-stream": "^1.6",
"amphp/dns": "^1 || ^0.9",
"ext-openssl": "*",
"kelunik/certificate": "^1.1",
"league/uri-parser": "^1.4",
"php": ">=7.1"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1",
"phpunit/phpunit": "^6 || ^7 || ^8",
"vimeo/psalm": "^3.9@dev"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Amp\\Socket\\": "src"
},
"files": [
"src/functions.php",
"src/Internal/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Lowrey",
"email": "rdlowrey@gmail.com"
},
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
}
],
"description": "Async socket connection / server tools for Amp.",
"homepage": "https://github.com/amphp/socket",
"keywords": [
"amp",
"async",
"encryption",
"non-blocking",
"sockets",
"tcp",
"tls"
],
"time": "2020-06-25T18:55:28+00:00"
},
{
"name": "amphp/sync",
"version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/sync.git",
"reference": "613047ac54c025aa800a9cde5b05c3add7327ed4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/sync/zipball/613047ac54c025aa800a9cde5b05c3add7327ed4",
"reference": "613047ac54c025aa800a9cde5b05c3add7327ed4",
"shasum": ""
},
"require": {
"amphp/amp": "^2.2",
"php": ">=7.1"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1.1",
"phpunit/phpunit": "^9 || ^8 || ^7"
},
"type": "library",
"autoload": {
"psr-4": {
"Amp\\Sync\\": "src"
},
"files": [
"src/functions.php",
"src/ConcurrentIterator/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
},
{
"name": "Stephen Coakley",
"email": "me@stephencoakley.com"
}
],
"description": "Mutex, Semaphore, and other synchronization tools for Amp.",
"homepage": "https://github.com/amphp/sync",
"keywords": [
"async",
"asynchronous",
"mutex",
"semaphore",
"synchronization"
],
"time": "2020-05-07T18:57:50+00:00"
},
{
"name": "amphp/windows-registry",
"version": "v0.3.3",
"source": {
"type": "git",
"url": "https://github.com/amphp/windows-registry.git",
"reference": "0f56438b9197e224325e88f305346f0221df1f71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/windows-registry/zipball/0f56438b9197e224325e88f305346f0221df1f71",
"reference": "0f56438b9197e224325e88f305346f0221df1f71",
"shasum": ""
},
"require": {
"amphp/amp": "^2",
"amphp/byte-stream": "^1.4",
"amphp/process": "^1"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master"
},
"type": "library",
"autoload": {
"psr-4": {
"Amp\\WindowsRegistry\\": "lib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
}
],
"description": "Windows Registry Reader.",
"funding": [
{
"url": "https://github.com/amphp",
"type": "github"
}
],
"time": "2020-07-10T16:13:29+00:00"
},
{
"name": "daverandom/libdns",
"version": "v2.0.2",
"source": {
"type": "git",
"url": "https://github.com/DaveRandom/LibDNS.git",
"reference": "e8b6d6593d18ac3a6a14666d8a68a4703b2e05f9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/DaveRandom/LibDNS/zipball/e8b6d6593d18ac3a6a14666d8a68a4703b2e05f9",
"reference": "e8b6d6593d18ac3a6a14666d8a68a4703b2e05f9",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"php": ">=7.0"
},
"suggest": {
"ext-intl": "Required for IDN support"
},
"type": "library",
"autoload": {
"psr-4": {
"LibDNS\\": "src/"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "DNS protocol implementation written in pure PHP",
"keywords": [
"dns"
],
"time": "2019-12-03T09:12:46+00:00"
},
{
"name": "kelunik/certificate",
"version": "v1.1.2",
"source": {
"type": "git",
"url": "https://github.com/kelunik/certificate.git",
"reference": "56542e62d51533d04d0a9713261fea546bff80f6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kelunik/certificate/zipball/56542e62d51533d04d0a9713261fea546bff80f6",
"reference": "56542e62d51533d04d0a9713261fea546bff80f6",
"shasum": ""
},
"require": {
"ext-openssl": "*",
"php": ">=5.4"
},
"require-dev": {
"fabpot/php-cs-fixer": "^1.9",
"phpunit/phpunit": "^4.8"
},
"type": "library",
"autoload": {
"psr-4": {
"Kelunik\\Certificate\\": "lib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
}
],
"description": "Access certificate details and transform between different formats.",
"keywords": [
"DER",
"certificate",
"certificates",
"openssl",
"pem",
"x509"
],
"time": "2019-05-29T19:02:31+00:00"
},
{
"name": "league/uri",
"version": "6.3.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/uri.git",
"reference": "aa3babf16e9d7535544bd94e3def026ac56640f3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/uri/zipball/aa3babf16e9d7535544bd94e3def026ac56640f3",
"reference": "aa3babf16e9d7535544bd94e3def026ac56640f3",
"shasum": ""
},
"require": {
"ext-json": "*",
"league/uri-interfaces": "^2.1",
"php": ">=7.2",
"psr/http-message": "^1.0"
},
"conflict": {
"league/uri-schemes": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^8.0"
},
"suggest": {
"ext-fileinfo": "Needed to create Data URI from a filepath",
"ext-intl": "Needed to improve host validation",
"league/uri-components": "Needed to easily manipulate URI objects"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "6.x-dev"
}
},
"autoload": {
"psr-4": {
"League\\Uri\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ignace Nyamagana Butera",
"email": "nyamsprod@gmail.com",
"homepage": "https://nyamsprod.com"
}
],
"description": "URI manipulation library",
"homepage": "http://uri.thephpleague.com",
"keywords": [
"data-uri",
"file-uri",
"ftp",
"hostname",
"http",
"https",
"middleware",
"parse_str",
"parse_url",
"psr-7",
"query-string",
"querystring",
"rfc3986",
"rfc3987",
"rfc6570",
"uri",
"uri-template",
"url",
"ws"
],
"funding": [
{
"url": "https://github.com/sponsors/nyamsprod",
"type": "github"
}
],
"time": "2020-08-13T17:18:44+00:00"
},
{
"name": "league/uri-interfaces",
"version": "2.1.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/uri-interfaces.git",
"reference": "0068a469958895ceaf3afcb489c0258adfa1e406"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/0068a469958895ceaf3afcb489c0258adfa1e406",
"reference": "0068a469958895ceaf3afcb489c0258adfa1e406",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^7.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^7.0|^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"League\\Uri\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ignace Nyamagana Butera",
"email": "nyamsprod@gmail.com",
"homepage": "https://nyamsprod.com"
}
],
"description": "Common interface for URI representation",
"homepage": "http://github.com/thephpleague/uri-interfaces",
"keywords": [
"rfc3986",
"rfc3987",
"uri",
"url"
],
"time": "2020-02-08T12:10:37+00:00"
},
{
"name": "league/uri-parser",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/uri-parser.git",
"reference": "671548427e4c932352d9b9279fdfa345bf63fa00"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/uri-parser/zipball/671548427e4c932352d9b9279fdfa345bf63fa00",
"reference": "671548427e4c932352d9b9279fdfa345bf63fa00",
"shasum": ""
},
"require": {
"php": ">=7.0.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0",
"phpstan/phpstan": "^0.9.2",
"phpstan/phpstan-phpunit": "^0.9.4",
"phpstan/phpstan-strict-rules": "^0.9.0",
"phpunit/phpunit": "^6.0"
},
"suggest": {
"ext-intl": "Allow parsing RFC3987 compliant hosts",
"league/uri-schemes": "Allow validating and normalizing URI parsing results"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"League\\Uri\\": "src"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ignace Nyamagana Butera",
"email": "nyamsprod@gmail.com",
"homepage": "https://nyamsprod.com"
}
],
"description": "userland URI parser RFC 3986 compliant",
"homepage": "https://github.com/thephpleague/uri-parser",
"keywords": [
"parse_url",
"parser",
"rfc3986",
"rfc3987",
"uri",
"url"
],
"time": "2018-11-22T07:55:51+00:00"
},
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2016-08-06T14:39:51+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "1.1.0"
}
<?php
use Amp\Delayed;
use Amp\Http\Client\HttpClientBuilder;
use Amp\Http\Client\Request;
use Amp\Http\Client\Response;
use Amp\Loop;
use function Amp\asyncCall;
require_once("vendor/autoload.php");
$time = microtime(true);
$result = [];
// async
asyncCall(function () use (&$result) {
$client = HttpClientBuilder::buildDefault();
$uris = [];
for ($i = 0; $i < 379; ++$i) {
$uris[] = "https://http2.akamai.com/demo/tile-$i.png";
}
$requestHandler = static function (string $uri) use ($client): Generator {
/** @var Response $response */
$response = yield $client->request(new Request($uri));
return yield $response->getBody()->buffer();
};
try {
$promises = [];
foreach ($uris as $uri) {
$promises[$uri] = Amp\call($requestHandler, $uri);
}
$bodies = yield $promises;
foreach ($bodies as $uri => $body) {
echo ".";
$result[] = $uri . " - " . strlen($body) . " bytes" . substr($body, 0, 30) . PHP_EOL;
}
} catch (HttpException $error) {
echo $error;
}
});
asyncCall(function () { // just add another coroutine.
for ($i = 0; $i < 3; ++$i) {
echo "+";
yield new Delayed(100);
}
});
echo PHP_EOL . "loop registered" . (microtime(true) - $time) . "sec" . PHP_EOL;
Loop::run(); // wait all
// var_dump($result); // result set
echo PHP_EOL . "para finish" . (microtime(true) - $time) . "sec" . PHP_EOL;
// sync
$time = microtime(true);
for ($i = 0; $i < 379; ++$i) {
$uri = "https://http2.akamai.com/demo/tile-$i.png";
$body = file_get_contents($uri);
echo "."; //$uri . " - " . \strlen($body) . " bytes" . substr($body, 0, 30) . PHP_EOL;
}
echo PHP_EOL . "sync finish" . (microtime(true) - $time) . "sec" . PHP_EOL;
/* sample result
+
loop registered0.09955906867981sec
++...........................................................................................................................................................................................................................................................................................................................................................................................
para finish0.89706420898438sec
...........................................................................................................................................................................................................................................................................................................................................................................................
sync finish18.918792963028sec
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment