PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
mainwp / class / class-mainwp-execution-helper.php

class-mainwp-execution-helper.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.0, at class/class-mainwp-execution-helper.php

88 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Counter
4 *
5 * @package MainWP/Dashboard
6 * @version 4.5.1
7 */
8
9 namespace MainWP\Dashboard;
10
11 /**
12 * Class MainWP_Execution_Helper
13 *
14 * @package MainWP\Dashboard
15 */
16 class MainWP_Execution_Helper {
17
18
19 /**
20 * Private variable to hold time start.
21 *
22 * @var int
23 */
24 private static $exec_start = null;
25
26 /**
27 * Private static varibale to hold the instance.
28 *
29 * @var mixed Default null
30 */
31 public static $instance = null;
32
33 /**
34 * Method instance()
35 *
36 * Returns new MainWP_Logger instance.
37 *
38 * @return self MainWP_Logger
39 *
40 * @uses \MainWP\Dashboard\MainWP_Logger
41 */
42 public static function instance() {
43 if ( null === self::$instance ) {
44 self::$instance = new self();
45 }
46 return self::$instance;
47 }
48
49 /**
50 * MainWP_Logger constructor.
51 *
52 * Run each time the class is called.
53 */
54 public function __construct() {
55 if ( null === self::$exec_start ) {
56 self::$exec_start = microtime( true );
57 }
58 }
59
60 /**
61 * Method init_exec_time().
62 *
63 * Init execution time start value.
64 */
65 public function init_exec_time() {
66 if ( null === self::$exec_start ) {
67 self::$exec_start = microtime( true );
68 }
69 MainWP_Logger::instance()->init_execution_time(); // compatible.
70 return self::$exec_start;
71 }
72
73 /**
74 * Method get_exec_time().
75 *
76 * Get execution time start value.
77 */
78 public function get_exec_time() {
79 if ( null === self::$exec_start ) {
80 self::$exec_start = microtime( true );
81 }
82
83 $sec = microtime( true ) - self::$exec_start; // seconds.
84 MainWP_Logger::instance()->log_action( 'execution time :: [value=' . round( $sec, 4 ) . '](seconds)', MainWP_Logger::EXECUTION_TIME_LOG_PRIORITY );
85 return $sec;
86 }
87 }
88