-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestAccess.php
More file actions
50 lines (37 loc) · 1.1 KB
/
testAccess.php
File metadata and controls
50 lines (37 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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);