Archive: December 03, 2003
"I'm really glad we're bombing countries, it's the only way I learn geography." - Jon Stewart (funny man)
Someone recently asked me in an e-mail how I generate the "This page took about x seconds to generate" message on my site. As I started to reply, and pasted the code I use into my e-mail client, I realized that this would work much better as a weblog entry (you get source-code highlighting here). So, here's how I do it:
I have one function, called timer().
<?php function timer($finish = false){ static $start_frac_sec, $start_sec, $end_frac_sec, $end_sec; if($finish){ list($end_frac_sec,$end_sec) = explode(" ", microtime()); echo '<p style="font-size: smaller">This page took about ' . round( ( ($end_sec - $start_sec) + ($end_frac_sec - $start_frac_sec) ), 4) . ' seconds to generate.</p>\n'; }else{ list($start_frac_sec,$start_sec) = explode(" ", microtime()); } } ?>
Because of the $finish parameter, you can use one function to both keep track of the time (which works without global variables because of the static variables) and print it when you're done. So, I call timer() around the start of my script, and timer(true) around the end of it.
One of the features I definitely need to get into my weblog after I get my new CMS done is draft posts. I've been wanting to do a big post on Federalism, states' rights, marriage, the Supreme Court, Christian Reconstruction, limited government, etc. But, I don't want to post something that's not done, and I don't want to be rushed to publish it just because I can't save it as a draft. So... feature request to myself.
Just like no blood for oil, I hope this is the last time I'll post on the Wilson/Plame "scandal". Reynolds has a post saying that the scandal is bogus because they're both obviously self-serving publicity-hounds. Absolutely Yes, and that's more wood on the fire. I've been arguing that this whole "scandal" is bogus for a while.
Ack! People actually write code like this? Run and hide! Though, these examples are small little monsters, like the tiny little Ash's in Army of Darkness, not like the big monster that comes out of Ash when he eats one of the little Ash's who makes sweet love to Ash's woman.
|
Generated in about 0.092s. (Used 7 db queries) |
new⇒Java join function
Meh, don't have null strings inyour string arrays imo, but you'rewelcome ...
Keith: Nov 19, 7:51pm