Permalink
Browse files

+ report

  • Loading branch information...
1 parent d7511ff commit 8a359bef00b9f53498b06816bde4290102d79432 @Alexxz committed Dec 26, 2011
View
@@ -1,3 +1,3 @@
sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
-#sudo service mysql restart
+sudo service mysql restart
#sleep 5
View
Binary file not shown.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,50 @@
+<?php
+chdir(dirname(__FILE__));
+include('conf.php');
+
+function getValuesForRandomAccess(){
+ $arr = array();
+ foreach(range(1, 10000) as $i){
+ $arr[] = rand(1,100000000);
+ }
+ return $arr;
+}
+
+function getValuesForSequencialAccess(){
+ $r = rand(1, 100000000-10000);
+ return range($r, $r+10000);
+}
+
+
+$conn = mysql_connect($config['host'], $config['user'], $config['pass']);
+if(!$conn){
+ die("Can't connect to MySQL server".PHP_EOL);
+}
+
+$res = mysql_select_db($config['db'], $conn);
+if(!$res){
+ die("There is an error in select query ".mysql_error($conn).PHP_EOL);
+}
+
+foreach(range(1, 10) as $i){
+ //$ids = getValuesForRandomAccess();
+ $ids = getValuesForSequencialAccess();
+
+ $values = implode(',',$ids);
+
+ $time = microtime(true);
+ $res = mysql_query("SELECT * FROM messages where message_id in ($values)", $conn);
+ $time = microtime(true)-$time;
+
+ $print_time = round($time * 1000);
+ echo "$print_time ms".PHP_EOL;
+
+ if(!$res){
+ die("There is an error in select query ".mysql_error($conn).PHP_EOL);
+ }
+
+ mysql_free_result($res);
+}
+
+
+mysql_close($conn);
View
@@ -26,6 +26,9 @@
}
mysql_select_db($config['db'], $conn) or die("Can't use database {$config['db']}".PHP_EOL);
+
+ $res = mysql_query("SELECT * FROM messages limit 1", $conn);
+ mysql_free_result($res);
////////////////////////////////////////////////
$time = microtime(true);
@@ -42,6 +45,7 @@
}
mysql_free_result($res);
+ mysql_close($conn);
}
View
@@ -28,6 +28,10 @@
if(!$res){
die("There is an error in select query ".mysql_error($conn).PHP_EOL);
}
+
+
+ $res = mysql_query("SELECT * FROM messages limit 1", $conn);
+ mysql_free_result($res);
////////////////////////////////////////////////
$time = microtime(true);
@@ -56,4 +60,5 @@
}
mysql_free_result($res);
+ mysql_close($conn);
}

0 comments on commit 8a359be

Please sign in to comment.