PHP code example of xp-forge / measure

1. Go to this page and download the library: Download xp-forge/measure library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xp-forge / measure example snippets


use util\profiling\{Measure, Measurable};

class Iteration extends Measurable {
  
  #[Measure]
  public function strpos() {
    return false === ($p= strpos('abc.', '.')) ? -1 : $p;
  }

  #[Measure]
  public function strcspn() {
    return 4 === ($p= strcspn('abc.', '.')) ? -1 : $p;
  }
}

use util\profiling\{Measure, Measurable, Values};

class Demo extends Measurable {

  #[Measure, Values(['', '.', '.a', 'a.', 'a.b'])]
  public function strpos($fixture) {
    return false === ($p= strpos($fixture, '.')) ? -1 : $p;
  }

  #[Measure, Values(['', '.', '.a', 'a.', 'a.b'])]
  public function strcspn($fixture) {
    return strlen($fixture) === ($p= strcspn($fixture, '.')) ? -1 : $p;
  }
}