Code Monkey home page Code Monkey logo

kirby3-stopwatch's Introduction

Kirby 3 Stopwatch

Release Downloads Build Status Coverage Status Maintainability
Twitter

Profile your Kirby 3 CMS code with precision in milliseconds (or seconds).

Commerical Usage


Support open source!

This plugin is free but if you use it in a commercial project please consider to sponsor me or make a donation.
If my work helped you to make some cash it seems fair to me that I might get a little reward as well, right?

Be kind. Share a little. Thanks.

โ€ Bruno
ย 
M O N E Y
Github sponsor Patreon Buy Me a Coffee Paypal dontation Hire me

Installation

  • unzip master.zip as folder site/plugins/kirby3-stopwatch or
  • git submodule add https://github.com/bnomei/kirby3-stopwatch.git site/plugins/kirby3-stopwatch or
  • composer require bnomei/kirby3-stopwatch

Works well with

Usage Site Method

Please read the Symfony Stopwatch Component Docs since this plugin is just a soft wrapper around it. Some Examples:

Event Duration

site()->stopwatch()->start('myevent');
sleep(1);
site()->stopwatch()->stop('myevent');
echo site()->stopwatch()->duration('myevent') . PHP_EOL; // float | int

Event with Laps aka Periods

$eventName = 'my event with laps';
$stopwatch = site()->stopwatch();
$stopwatch->start($eventName);
foreach ([random_int(100,500),random_int(100,500),random_int(100,500)] as $time) {
    usleep($time);
    $stopwatch->lap($eventName);
}
usleep(100);
$stopwatch->stop($eventName);
$totalDuration = $stopwatch->duration($eventName); // float | int
echo $totalDuration . PHP_EOL;
foreach ($stopwatch->getEvent($eventName)->getPeriods() as $period) {
    echo $period->getDuration() . PHP_EOL;  // float | int
}

Usage PHP Class

You can use the provided php class in your own classes if you make sure the class is loaded before you call it. This can be done in installing this plugin using composer or in manually requiring it with Kirby's class loader.

$stopwatch = \Bnomei\Stopwatch::singleton();
$stopwatch->start('my event with laps');
sleep(1);
$stopwatch->stop('my event with laps');
$duration = $stopwatch->duration('my event with laps'); // float | int

Settings

bnomei.stopwatch. Default Description
precision true measure microseconds as float or int seconds.

NOTE: This plugin defaults to measuring in milliseconds but the symfony component does not.

Dependencies

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.

kirby3-stopwatch's People

Contributors

bnomei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kirby3-stopwatch's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.