# cf7-grid-layout/4.5/assets/class-execution-time.php

Smart Grid-Layout Design for Contact Form 7, version 4.5. 42 lines.

- Page: https://pluginprobe.com/plugins/cf7-grid-layout/4.5/code/assets/class-execution-time.php
- Raw: https://pluginprobe.com/plugins/cf7-grid-layout/4.5/raw/assets/class-execution-time.php
- Modified: 2017-11-13T07:39:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/cf7-grid-layout/4.5/code/assets/class-execution-time.php#L10-L20`.

```php
<?php
/* Usage...
if(true === WP_DEBUG){
require_once(plugin_dir_path(__DIR__).'/assets/class-execution-time.php');
$executionTime = new ExecutionTime('cf7_shortcode_request');
$executionTime->Start();
}
//code
if(true === WP_DEBUG){
$executionTime->End();
debug_msg($executionTime->__toString());
}


*/
class ExecutionTime{
     private $startTime;
     private $endTime;
     private $fn;
     public function __construct($fn_name){
          $this->fn = $fn_name;
     }
     public function Start(){
         $this->startTime = getrusage();
     }

     public function End(){
         $this->endTime = getrusage();
     }

     private function runTime($ru, $rus, $index) {
         return ($ru["ru_$index.tv_sec"]*1000 + intval($ru["ru_$index.tv_usec"]/1000))
     -  ($rus["ru_$index.tv_sec"]*1000 + intval($rus["ru_$index.tv_usec"]/1000));
     }

     public function __toString(){
         return $this->fn." used " . $this->runTime($this->endTime, $this->startTime, "utime") .
        " ms for its computations\nIt spent " . $this->runTime($this->endTime, $this->startTime, "stime") .
        " ms in system calls\n";
     }
 }

```
