web development war stories from the frontlines to the backend

Spending most of the day optimizing a page that (when I began) took 8.6 seconds to execute. Using some basic profiling techniques helped tremendously in not wasting my time and efforts attempting to optimize a portion of code that won’t yield appreciable gains.
The time intensive code for applications I write generally fall into either [...]

Had to quickly get the execution time of certain segments of code so I whipped up this basic profiling class below.
Usage would go something like:

<?php
$profiler = new cProfiler;
$profiler->start();
// … long block of code …
$et = $profiler->end();
echo ‘longBlock et = ‘.$et.’<br>’;
?>

Class listing cProfiler.php:

<?php

class cProfiler
{
public $_i;

public $stamps;
public $ets;

function __construct()
{
$this->_i = 0;
$this->stamps = array();
$this->ets = array();
}

function __destruct() {}

function [...]

  

Recent Posts

Categories

Archives