承接 almasmurad/stopwatch 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

almasmurad/stopwatch

最新稳定版本:0.4.4

Composer 安装命令:

composer require almasmurad/stopwatch

包简介

Component for measuring code execution time

README 文档

README

PHP tool that measures code execution time.

README in Russian

Usage

// create Stopwatch
$stopwatch = new Almasmurad\Stopwatch\Stopwatch();

// start measuring the first step
$stopwatch->start('code section #1');
//...

// start measuring the second step
$stopwatch->step('code section #2');
//...

// start measuring the third step
$stopwatch->step('code section #3');
//...

// finish measuring
$stopwatch->finish();

// output the report
$stopwatch->report();

As a result, the following report gets into the standard output:

 Start           | 06:55:14.123 
-----------------|--------------
 code section #1 |      0.198 s 
 code section #2 |      0.209 s 
 code section #3 |      1.200 s 
-----------------|--------------
 Summary         |      1.607 s 

Minimal Usage

$stopwatch = new Almasmurad\Stopwatch\Stopwatch();

//... (measured code)

$stopwatch->report();

As a result, the following report gets into the standard output:

 Start   | 06:55:14.123 
---------|--------------
 Summary |      0.198 s 

Output Report to File

$stopwatch->reportToFile(__DIR__.'/report.txt');

Report will be written to a file, and nothing will get into the standard output. If the file already exists, the report will replace its contents. In order for the report to append the contents of the file, use another method:

$stopwatch->reportToFileInAppendMode(__DIR__.'/report.txt');

Access to the Report Components

Instead of outputting the report to a standard stream or file, you can access its components:

// getting the report object
$report = $stopwatch->getReport();

// general indicators
$start   = $report->getStart()->getTimestamp();   // stopwatch start time
$finish  = $report->getFinish()->getTimestamp();  // stopwatch finish time
$elapsed = $report->getElapsed()->getSeconds();   // time of the entire stopwatch operation

// indicators of first code section 
$step1_start   = $report->getStepByIndex(0)->getStart()->getTimestamp();   
$step1_finish  = $report->getStepByIndex(0)->getFinish()->getTimestamp();  
$step1_elapsed = $report->getStep('code section #1')->getElapsed()->getSeconds();

// all of code sections
foreach ($report->getSteps() as $step){
    //...
}

You can read more about the report object in the section 'Report object'

Learn More

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固