I need a simple way to test SQL queries for speed. I am not to worried about hardware differences, I basically need a relative number.
This is what I've been doing with PHP (its fuzzy, but works):
// CONNECT TO DB HERE
$sub = new YomoSubscription(95,783);
$t = microtime(TRUE);
// contains the SQL db call i'm testing
$fp = $sub->generateFingerprint();
echo microtime(TRUE)-$t;
The PROBLEM I am having is that, sometimes on initial connect/run my test takes 1.25 sec for example. However on subsequent connects it takes 0.004 sec ... Why is this?
I'm pretty sure MySQL query cache is off in my.ini:
query_cache_size=0