Tag: time Archives Not Just A Random Blog

06/30/2011

Image & URI Convertor Tool

by Cyle — Categories: tools — Tags: , , , Leave a comment

Use this simple tool to convert an image into base 64 data URIs for embedding images. If you want to convert a base 64 data URI to an image click here or scroll down.



Max file size: 500 Kb
File Types: *.gif, *.jpg, *.jpeg, *.png

Note: It is best if the image is optimized to the smallest file size possible before converting it to a base 64 data URI!! Here is a great online image optimization tool.

 

What Are Data URIs?

Data URIs are used to embed images into other files so that the image is like “immediate” data. This is known as inline images, and can be embedded many places like in your CSS, <img src... tag, email messages, and more. Read More » »

06/21/2011

Measuring Execution Time With PHP

by Cyle — Categories: php — Tags: , , , , 1 Comment

Some websites have how long it took to execute the website near the bottom of their pages. This can be entertaining, but it also servers another important purpose. I often use it to see if one of my pages is taking too long to load or hanging. To use this simple script, place this code at the top of your script:

<?php
function getCurTime()
    {
    $time = explode (' ',microtime());
    return(double) $time[0] + $time[1];
    }
$startTime = getCurTime();
?>

And this at the bottom of your script:

<?php
$endTime = getCurTime();
echo "Time to Execute = ".number_format(($endTime - $startTime),2)." seconds";
?>

You can change the “2″ in the number_format() function to however many decimal places you want. Below it is set to 6. If you notice your webpage taking too long to load, but not sure what piece is holding it up, you can move the script to the middle of the script or somewhere else and try to narrow it down that way.

Below is the same script but instead of measuring the execution time for the entire page, it just calculates the time it takes to execute the content of this blog post.

Time to Execute = 0.000017 seconds

© 2013 Not Just A Random Blog All rights reserved - Theme by ([][]) TwoBeers