Skip to content

Commit 520e6b9

Browse files
committed
✨ add sylynder/codeigniter to sylynder/engine
Signed-off-by: otengkwame <[email protected]>
1 parent 95a9e3f commit 520e6b9

File tree

200 files changed

+67731
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+67731
-0
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?php
2+
3+
/**
4+
* CodeIgniter
5+
*
6+
* An open source application development framework for PHP
7+
*
8+
* This content is released under the MIT License (MIT)
9+
*
10+
* Copyright (c) 2019 - 2022, CodeIgniter Foundation
11+
*
12+
* Permission is hereby granted, free of charge, to any person obtaining a copy
13+
* of this software and associated documentation files (the "Software"), to deal
14+
* in the Software without restriction, including without limitation the rights
15+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16+
* copies of the Software, and to permit persons to whom the Software is
17+
* furnished to do so, subject to the following conditions:
18+
*
19+
* The above copyright notice and this permission notice shall be included in
20+
* all copies or substantial portions of the Software.
21+
*
22+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28+
* THE SOFTWARE.
29+
*
30+
* @package CodeIgniter
31+
* @author EllisLab Dev Team
32+
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
33+
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
34+
* @copyright Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
35+
* @license https://opensource.org/licenses/MIT MIT License
36+
* @link https://codeigniter.com
37+
* @since Version 1.0.0
38+
* @filesource
39+
*/
40+
defined('BASEPATH') or exit('No direct script access allowed');
41+
42+
/**
43+
* Benchmark Class
44+
*
45+
* This class enables you to mark points and calculate the time difference
46+
* between them. Memory consumption can also be displayed.
47+
*
48+
* @package CodeIgniter
49+
* @subpackage Libraries
50+
* @category Libraries
51+
* @author EllisLab Dev Team
52+
* @link https://codeigniter.com/userguide3/libraries/benchmark.html
53+
*/
54+
class CI_Benchmark
55+
{
56+
57+
/**
58+
* List of all benchmark markers
59+
*
60+
* @var array
61+
*/
62+
public $marker = [];
63+
64+
/**
65+
* Set a benchmark marker
66+
*
67+
* Multiple calls to this function can be made so that several
68+
* execution points can be timed.
69+
*
70+
* @param string $name Marker name
71+
* @return void
72+
*/
73+
public function mark($name)
74+
{
75+
$this->marker[$name] = microtime(true);
76+
}
77+
78+
// --------------------------------------------------------------------
79+
80+
/**
81+
* Elapsed time
82+
*
83+
* Calculates the time difference between two marked points.
84+
*
85+
* If the first parameter is empty this function instead returns the
86+
* {elapsed_time} pseudo-variable. This permits the full system
87+
* execution time to be shown in a template. The output class will
88+
* swap the real value for this variable.
89+
*
90+
* @param string $point1 A particular marked point
91+
* @param string $point2 A particular marked point
92+
* @param int $decimals Number of decimal places
93+
*
94+
* @return string Calculated elapsed time on success,
95+
* an '{elapsed_string}' if $point1 is empty
96+
* or an empty string if $point1 is not found.
97+
*/
98+
public function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
99+
{
100+
if ($point1 === '') {
101+
return '{elapsed_time}';
102+
}
103+
104+
if ( ! isset($this->marker[$point1])) {
105+
return '';
106+
}
107+
108+
if ( ! isset($this->marker[$point2])) {
109+
$this->marker[$point2] = microtime(true);
110+
}
111+
112+
return number_format($this->marker[$point2] - $this->marker[$point1], $decimals);
113+
}
114+
115+
// --------------------------------------------------------------------
116+
117+
/**
118+
* Memory Usage
119+
*
120+
* Simply returns the {memory_usage} marker.
121+
*
122+
* This permits it to be put it anywhere in a template
123+
* without the memory being calculated until the end.
124+
* The output class will swap the real value for this variable.
125+
*
126+
* @return string '{memory_usage}'
127+
*/
128+
public function memory_usage()
129+
{
130+
return '{memory_usage}';
131+
}
132+
}

0 commit comments

Comments
 (0)