hhpack/performance
Composer 安装命令:
composer require hhpack/performance
包简介
Performance utility library for Hack
README 文档
README
Basic usage
You can measure the time of easy processing.
use HHPack\Performance\PerformanceWatcher; use HHPack\Performance\TimeWatcher; use HHPack\Performance\MemoryWatcher; use HHPack\Performance\Result\WatchedResult; $watcher = PerformanceWatcher::fromItems([ Pair { 'time', new TimeWatcher() }, Pair { 'memory', new MemoryWatcher() } ]); $watcher->start(); $watcher->stop(); $texts = $watcher->result()->mapWithKey(($key, $result) ==> { return sprintf("%s: %s", $key, (string) $result->value()); })->values(); foreach ($texts as $text) { echo $text, PHP_EOL; }
Benchmark
use HHPack\Performance as bench; function sync_benchmarker() : void { bench\sync()->times(10)->run(() ==> { usleep(2000); }); } sync_benchmarker();
or
use HHPack\Performance as bench; async function async_benchmarker_main() : Awaitable<void> { await bench\async()->times(10)->run(async () ==> { await \HH\Asio\usleep(2000); }); } \HH\Asio\join(async_benchmarker_main());
Run the test
You can run the test with the following command.
composer install
composer test
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-17
