From 1ea131c6043ca3f6dcf8354ec76becf3a722d5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Thu, 19 Sep 2019 15:57:14 +0200 Subject: [PATCH] Update benchmark output and results --- README.md | 16 ++++++++-------- examples/benchmark-exec.php | 12 +++++++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0cd087e..3bf3a87 100644 --- a/README.md +++ b/README.md @@ -227,14 +227,14 @@ See also the [streaming exec example](examples/exec-stream.php) and the [exec be The TTY mode should be set depending on whether your command needs a TTY or not. Note that toggling the TTY mode affects how/whether you can access the STDERR stream and also has a significant impact on performance for -larger streams (relevant for 100 MiB and above). See also the TTY mode -on the `execStart*()` call. - -Running this benchmark on my personal (rather mediocre) VM setup reveals that -the benchmark achieves a throughput of ~300 MiB/s while the (totally unfair) -comparison script using the plain Docker client only yields ~100 MiB/s. -Instead of me posting more details here, I encourage you to re-run the benchmark -yourself and adjust it to better suite your problem domain. +larger streams (relevant for hundreds of megabytes and more). See also the TTY +mode on the `execStart*()` call. + +Running the provided benchmark example on a range of systems, it suggests that +this library can process several gigabytes per second and may in fact outperform +the Docker client and seems to be limited only by the Docker Engine implementation. +Instead of posting more details here, you're encouraged to re-run the benchmarks +yourself and see for yourself. The key takeway here is: *PHP is faster than you probably thought*. #### TAR streaming diff --git a/examples/benchmark-exec.php b/examples/benchmark-exec.php index 9f139f9..c3c904c 100644 --- a/examples/benchmark-exec.php +++ b/examples/benchmark-exec.php @@ -1,8 +1,14 @@ on('close', function () use ($client, &$bytes, $start) { $time = microtime(true) - $start; - echo 'Received ' . $bytes . ' bytes in ' . round($time, 1) . 's => ' . round($bytes / $time / 1024 / 1024, 1) . ' MiB/s' . PHP_EOL; + echo 'Received ' . $bytes . ' bytes in ' . round($time, 1) . 's => ' . round($bytes / $time / 1000000, 1) . ' MB/s' . PHP_EOL; }); }, 'printf');