Overview

Namespaces

  • None
  • PHP
  • Pry
    • Auth
      • Interfaces
    • Config
    • Controller
    • Date
    • Db
    • Feed
      • Abstracts
      • Writers
    • File
      • Decorator
    • Form
      • Element
    • Image
    • Log
      • Writer
    • Net
      • Exception
    • Session
    • Util
    • Validate
      • Validator
    • View

Classes

  • Bench
  • CommandLineBuilder
  • Pagination
  • Registry
  • Strings
  • Token
  • UserAgent

Exceptions

  • ExceptionHandler
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * Pry Framework
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file LICENSE.txt.
 10:  * 
 11:  */
 12: 
 13: namespace Pry\Util;
 14: 
 15: /**
 16:  * Classe bench. Mesure de performance de script php avec possibilité d'ajout de flag intermédiaire.
 17:  * 
 18:  * @category Pry
 19:  * @package Util
 20:  * @version 1.0.3
 21:  * @author Olivier ROGER <oroger.fr>
 22:  * 
 23:  */
 24: class Bench // Amel bench ? ==>[]
 25: {
 26: 
 27:     /**
 28:      * Temps de début.<br />Valeur par défaut : 0
 29:      * @var int
 30:      * @access private
 31:      */
 32:     private $start;
 33: 
 34:     /**
 35:      * Tableau de résultat.
 36:      * @var array
 37:      * @access public
 38:      */
 39:     private $resultat;
 40: 
 41:     /**
 42:      * Constructeur.
 43:      * Initialisation des valeurs
 44:      *
 45:      */
 46:     public function __construct()
 47:     {
 48:         $this->start    = 0;
 49:         $this->resultat = array();
 50:     }
 51: 
 52:     /**
 53:      * Départ.
 54:      * Lance le début du calcul de temps
 55:      *
 56:      */
 57:     public function start()
 58:     {
 59:         $this->start = $this->get_micro();
 60:     }
 61: 
 62:     /**
 63:      * Prend un temps intermédiaire.
 64:      *
 65:      * @param $nom Nom du temps intermédiaire
 66:      */
 67:     public function add_flag($nom)
 68:     {
 69:         $top                  = $this->get_micro() - $this->start;
 70:         $this->resultat[$nom] = $top;
 71:     }
 72: 
 73:     /**
 74:      * Arrete le calcul.
 75:      *
 76:      */
 77:     public function stop()
 78:     {
 79:         $end                     = $this->get_micro() - $this->start;
 80:         $this->resultat['total'] = $end;
 81:     }
 82: 
 83:     /**
 84:      * Donne les tableau de résultat.
 85:      *
 86:      * @return Tableau de résultats.
 87:      */
 88:     public function result()
 89:     {
 90:         return $this->resultat;
 91:     }
 92: 
 93:     /**
 94:      * Donne les miliseconde
 95:      * @access private
 96:      * @return Float temps en milisecondes
 97:      */
 98:     private function get_micro()
 99:     {
100:         $temps = microtime();
101:         $temps = explode(' ', $temps);
102:         $temps = $temps[1] + $temps[0];
103:         return (float) $temps;
104:     }
105: 
106: }
Pry API documentation generated by ApiGen 2.8.0