PluginProbe
Smart Grid-Layout Design for Contact Form 7 / 3.3.3
Smart Grid-Layout Design for Contact Form 7 v3.3.3
4.18.0 4.17.0 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 4.0.0 4.0.1 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10 4.11 4.12 4.13 4.14 All 119 releases
cf7-grid-layout / assets / class-execution-time.php

class-execution-time.php in Smart Grid-Layout Design for Contact Form 7 3.3.3, at assets/class-execution-time.php

42 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /* Usage...
3 if(true === WP_DEBUG){
4 require_once(plugin_dir_path(__DIR__).'/assets/class-execution-time.php');
5 $executionTime = new ExecutionTime('cf7_shortcode_request');
6 $executionTime->Start();
7 }
8 //code
9 if(true === WP_DEBUG){
10 $executionTime->End();
11 debug_msg($executionTime->__toString());
12 }
13
14
15 */
16 class ExecutionTime{
17 private $startTime;
18 private $endTime;
19 private $fn;
20 public function __construct($fn_name){
21 $this->fn = $fn_name;
22 }
23 public function Start(){
24 $this->startTime = getrusage();
25 }
26
27 public function End(){
28 $this->endTime = getrusage();
29 }
30
31 private function runTime($ru, $rus, $index) {
32 return ($ru["ru_$index.tv_sec"]*1000 + intval($ru["ru_$index.tv_usec"]/1000))
33 - ($rus["ru_$index.tv_sec"]*1000 + intval($rus["ru_$index.tv_usec"]/1000));
34 }
35
36 public function __toString(){
37 return $this->fn." used " . $this->runTime($this->endTime, $this->startTime, "utime") .
38 " ms for its computations\nIt spent " . $this->runTime($this->endTime, $this->startTime, "stime") .
39 " ms in system calls\n";
40 }
41 }
42