WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Code Execution Time Calculator
Categories : PHP, PHP Classes, Date Time Click here to Update Your Picture
Joshy Jacob
Date : Aug 21st 2006
Grade : 3 of 5 (graded 1 times)
Viewed : 4031
File : 4481.php
Images : No Images for this code example.
Search : More code by Joshy Jacob
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

ExecutionTime.class.php
<?php
//==========================================================================//
//  The Class
//**************************************************************************//
class ExecutionTime
{
   
// Class Constructor
   
function ExecutionTime()
    {
       
// Initialize variables
       
$this->ExecutionStart();
       
$this->ExecutionEnd();
       
$this->Msg = "Execution took <b>%f</b> seconds to complete.";
    }

   
// This Function is to be called before the start of Execution
   
function ExecutionStart()
    {
       
$this->StartTime = $this->GetMicroTime();
    }

   
// This Function is to be called at the End of Execution
   
function ExecutionEnd()
    {
       
$this->EndTime = $this->GetMicroTime();
    }
   
   
// This Function returns the time taken for the code execution
   
function GetExecutionTime()
    {
        return
$this->EndTime - $this->StartTime;
    }

    function
PrintTime($Msg = 0)
    {
       
$Msg = !$Msg ? $this->Msg : $Msg;
       
// If the Start and End times are the same take the End time as current time
       
if($this->EndTime == $this->StartTime)
        {
           
$this->EndTime = $this->GetMicroTime();
        }
       
printf($Msg, $this->GetExecutionTime());
    }

   
// This function helps in returning the result as float
    // even in PHP 4
   
function GetMicroTime()
    {
        list(
$MicroSec, $Sec) = explode(" ", microtime());
        return ((float)
$MicroSec + (float)$Sec);
    }
}
?>





Example Usage
<?php
include_once ("ExecutionTime.class.php");

$ET = new ExecutionTime;
$ET->ExecutionStart();
// Execute Code Here

sleep(2);

// Code Execution Ends
$ET->ExecutionEnd();
echo
"The code execution started at " . date('g:i:s A', $ET->StartTime) . " and ended at ". date('g:i:s A', $ET->EndTime)."<br />";
$ET->PrintTime();
?>



A Timing Class
Categories : PHP, PHP Classes, Date Time
pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes
A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function.
Categories : PHP, PHP Classes, Calendar, Date Time
Open and Close your website in fixed times .
Categories : PHP, PHP Classes, Cron, Date Time
Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example.
Categories : PHP, Date Time, PHP Classes, Calendar
Validator - A PHP class that can can be used for validating Email IDs and Dates
Categories : PHP, PHP Classes, Data Validation, Email, Date Time
A time measuring and performance benchmarking class
Categories : PHP, PHP Classes, Testing, Debugging, Date Time
Bs_StopWatch is a class to measure time intervals in microseconds.
Categories : PHP, Date Time, PHP Classes
Customizable Calendar Class
Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar
a class that uses microtime() to provide easy calculation of elapsed times
Categories : Date Time, PHP, PHP Classes
very simple ftp class
Categories : PHP, PHP Classes, FTP
PHP Paypal IPN Integration Class v1.0.0
Categories : PHP, PHP Classes, Payment Gateways
The class to check load time of your script VERY usefull for relatively slow applications, but not only..
Categories : PHP, PHP Classes, Debugging
Create HTML forms dynamicly using Javascript & PHP
Categories : PHP, PHP Classes, Java Script
usercounter class
Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables