All Projects → antonioribeiro → support

antonioribeiro / support

Licence: BSD-3-Clause license
Support Classes

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to support

Meteor-Template-helpers
Template helpers for Session, logical operations and debug
Stars: ✭ 35 (-37.5%)
Mutual labels:  helpers
react-semantic-render
Semantic helper components for rendering content with React.
Stars: ✭ 13 (-76.79%)
Mutual labels:  helpers
android-helpers
Android helpers collection
Stars: ✭ 20 (-64.29%)
Mutual labels:  helpers
SQLServerTools
This repo is the home of various SQL-Server-Tools
Stars: ✭ 28 (-50%)
Mutual labels:  helpers
ngx-file-helpers
Angular File Helpers
Stars: ✭ 34 (-39.29%)
Mutual labels:  helpers
utils
⚡ A collection of common functions but with better performance, less allocations and less dependencies created for Fiber.
Stars: ✭ 21 (-62.5%)
Mutual labels:  helpers
Ember Native Dom Helpers
Test helpers for your integration tests that fire native events
Stars: ✭ 187 (+233.93%)
Mutual labels:  helpers
redux-fp
Functional programming helpers for Redux.
Stars: ✭ 28 (-50%)
Mutual labels:  helpers
php-helpers
An extensive set of PHP helper functions and classes.
Stars: ✭ 27 (-51.79%)
Mutual labels:  helpers
Milvasoft
Helper structures for .Net 6 projects.
Stars: ✭ 24 (-57.14%)
Mutual labels:  helpers
timelite
String date and time utilities 🕙
Stars: ✭ 17 (-69.64%)
Mutual labels:  helpers
MADE.NET
MADE.NET is a home to all of those bits of code that you know you'll reuse in another project. Making app development easier with .NET.
Stars: ✭ 75 (+33.93%)
Mutual labels:  helpers
UnityCommon
A collection of common frameworks and tools for Unity-based projects
Stars: ✭ 61 (+8.93%)
Mutual labels:  helpers
UnPack.jl
`@pack!` and `@unpack` macros
Stars: ✭ 74 (+32.14%)
Mutual labels:  helpers
three-stdlib
📚 Stand-alone library of threejs examples designed to run without transpilation in node & browser
Stars: ✭ 380 (+578.57%)
Mutual labels:  helpers
Prosemirror Utils
⚒ Utils library for ProseMirror
Stars: ✭ 241 (+330.36%)
Mutual labels:  helpers
laravel-helper-functions
Laravel-specific and pure PHP Helper Functions.
Stars: ✭ 106 (+89.29%)
Mutual labels:  helpers
ideas
Идеи по улучшению языка C++ для обсуждения
Stars: ✭ 65 (+16.07%)
Mutual labels:  helpers
php-lodash
php-lodash is a PHP utility library, similar to Underscore/Lodash.
Stars: ✭ 35 (-37.5%)
Mutual labels:  helpers
support
Collection of agnostic PHP Functions and helpers with zero dependencies to use as foundation in packages and other project
Stars: ✭ 54 (-3.57%)
Mutual labels:  helpers

Support

Timer

A timer class that can be called static or dynamically.

Source code: support/blob/master/src/Timer.php

Methods

Those are the methods:

Timer::start();
Timer::stop();
Timer::isStarted();
Timer::isStopped();
Timer::elapsed(); // returns a formatted value 9.0192
Timer::elapsedRaw(); // returns a double 9.019223049023
Timer::setFormat(default = '%.4f');

You can name your timers and have more than one running:

Timer::start('mary');
Timer::stop('mary');
Timer::elapsed('mary');

Examples

Timer::start();
Timer::start('2nd timer');

var_dump("started: " . (Timer::isStarted() ? 'yes' : 'no'));
var_dump("stopped: " . (Timer::isStopped() ? 'yes' : 'no'));

sleep(5);

Timer::stop();

var_dump("started: " . (Timer::isStarted() ? 'yes' : 'no'));
var_dump("stopped: " . (Timer::isStopped() ? 'yes' : 'no'));
var_dump("elapsed: " . Timer::elapsed());
var_dump("raw: " . Timer::elapsedRaw());

sleep(2);

var_dump("'2nd timer' started: " . (Timer::isStarted('2nd timer') ? 'yes' : 'no'));
var_dump("'2nd timer' stopped: " . (Timer::isStopped('2nd timer') ? 'yes' : 'no'));
var_dump("'2nd timer' elapsed: " . Timer::elapsed('2nd timer'));
var_dump("'2nd timer' raw: " . Timer::elapsedRaw('2nd timer'));

sleep(2);

Timer::stop('2nd timer');

var_dump("'2nd timer' started: " . (Timer::isStarted('2nd timer') ? 'yes' : 'no'));
var_dump("'2nd timer' stopped: " . (Timer::isStopped('2nd timer') ? 'yes' : 'no'));
var_dump("'2nd timer' elapsed: " . Timer::elapsed('2nd timer'));
var_dump("'2nd timer' raw: " . Timer::elapsedRaw('2nd timer'));

Timer::setFormat('%.8f');
var_dump("'2nd timer' elapsed 8 decimals: " . Timer::elapsed('2nd timer'));

/// And you can instantiate it and do it all over again:

$t = new Timer;
$t->start();
sleep(3);
$t->stop();
var_dump("elapsed dynamic: " . $t->elapsed());

This should give you this result:

string(12) "started: yes"
string(11) "stopped: no"
string(11) "started: no"
string(12) "stopped: yes"
string(15) "elapsed: 5.0004"
string(20) "raw: 5.0005040168762"
string(24) "'2nd timer' started: yes"
string(23) "'2nd timer' stopped: no"
string(27) "'2nd timer' elapsed: 7.0008"
string(32) "'2nd timer' raw: 7.0008120536804"
string(23) "'2nd timer' started: no"
string(24) "'2nd timer' stopped: yes"
string(27) "'2nd timer' elapsed: 9.0011"
string(32) "'2nd timer' raw: 9.0010931491852"
string(42) "'2nd timer' elapsed 8 decimals: 9.00113106"
string(27) "elapsed dynamic: 3.00018883"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].