quillstack/benchmark 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

quillstack/benchmark

Composer 安装命令:

composer require quillstack/benchmark

包简介

Bash/PHP script to benchmark HTTP requests and command line scripts.

README 文档

README

StyleCI Build Status CodeFactor Downloads Packagist PHP Version Support Packagist License

This repository contains a script to test HTTP GET requests or command line calls.

PHP usage

You can install this package using Composer:

composer require --dev quillstack/benchmark

In PHP console you can use this library by running commands:

List available commands

If you installed this library as a package in your project, you can run these commands:

List of available commands
./vendor/bin/benchmark
HTTP GET requests
./vendor/bin/benchmark benchmark:http:get https://example.org 10 2
Command line calls
./vendor/bin/benchmark benchmark:console "php ../test.php" 10 2

Cloned reposotiry

If you cloned this repository to your local computer, use these commands:

./bin/local
./bin/local benchmark:http:get https://example.org 10 2
./bin/local benchmark:console "php ../test.php" 10 2

To see detailed descriptions for every command, ready Bash usage below.

Bash usage

You can also use Bash commands to run benchmarks. These commands work only if you clone this repository to your computer or server.

HTTP GET requests

Usage:

./http_get.sh https://example.org 10 2

Where:

  • 10 is a total number of requests
  • 2 is a number of concurrent requests

Output:

10 requests, 2 concurrently
URL https://example.org
--------------------------------------------------------------------
Took 2.468000 s, 4.051864 requests per second, 0.469415 avg req time

What means we sent 10 GET requests to this host. We decided to send two requests at the time. The entire test took around 2.5 seconds. It means the website could server 4 requests per second with 0.5 seconds the average response time.

Command line calls

If you want to test command line calls, be sure every call respond with an execution time (in seconds):

0.001699

For PHP the script could look like:

<?php

require __DIR__ . '/../vendor/autoload.php';

$start = microtime(true);

$container = new Container();
$service = $container->get(ExampleService::class);

$time = microtime(true) - $start;
$roundedTime = round($time, 6);

echo $roundedTime . PHP_EOL;

Usage example:

./command_line.sh "php ../test.php" 10 2

Output:

10 calls, 2 concurrently
Command `php ../test.php`
-------------------------------------------------------------------
Took 0.247000 s, 40.485830 calls per second, 0.001087 avg call time

The results say we called the script 10 times with 2 concurrently calls. Our test took around 250 milliseconds, what means we could call this script 40 times per seconds, and average call time would be 1 millisecond.

Different results

You can have different results for different parameters. For example the results for the same script:

./command_line.sh "php ../test.php" 1000 100

are different for these parameters:

1000 calls, 100 concurrently
Command `php ../test.php`
-------------------------------------------------------------------
Took 7.760000 s, 128.865979 calls per second, 0.080927 avg call time

Because we increased the number of concurrent calls.

If we use the same concurrent calls like in the first command line example:

./command_line.sh "php ../test.php" 1000 2

The results should be similar to the first ones:

1000 calls, 2 concurrently
Command `php ../di/public/index.php`
-------------------------------------------------------------------
Took 22.795000 s, 43.869270 calls per second, 0.001178 avg call time

What gives use around 40 calls per second, if we have two concurrent calls.

Quill Stack

If you want to know more about other solutions, visit the website:
https://quillstack.com/

The Quill Stack

quillstack/benchmark 适用场景与选型建议

quillstack/benchmark 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 09 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 quillstack/benchmark 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 quillstack/benchmark 我们能提供哪些服务?
定制开发 / 二次开发

基于 quillstack/benchmark 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-03