update phpd subrepo
This commit is contained in:
parent
d80118b35f
commit
12495e10f8
|
@ -7,6 +7,21 @@
|
|||
# USAGE
|
||||
# ./configure -- configure local machine
|
||||
# ./configure -c -- collect local configure files
|
||||
#
|
||||
# NOTE
|
||||
# check $PATH include
|
||||
# /usr/local/sbin
|
||||
# /usr/local/bin
|
||||
# /usr/sbin
|
||||
# /usr/bin
|
||||
# /sbin
|
||||
# /bin
|
||||
#
|
||||
# AUTHOR
|
||||
# Aborn Jiang (aborn.jiang@gmail.com)
|
||||
#
|
||||
# VERSION
|
||||
# v0.1 2014-03-04
|
||||
###############################################################
|
||||
ABSPATH=$(dirname $0)
|
||||
cd ${ABSPATH}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
require_once('mysql2redis.php');
|
||||
$items_number=2000000;
|
||||
$tab_redis = new mysql2redis();
|
||||
$tab_redis->setTBname('bench');
|
||||
$tab_redis->setDBname('test');
|
||||
$tab_redis->setTBname('bench');
|
||||
$tab_redis->bench($items_number);
|
||||
$tab_redis->bench($items_number, 'bench_no_index');
|
||||
?>
|
||||
|
|
|
@ -33,6 +33,11 @@ class dbops {
|
|||
}
|
||||
}
|
||||
|
||||
public function tabsize($sql)
|
||||
{
|
||||
return $this->mysqli->query($sql);
|
||||
}
|
||||
|
||||
public function query($sql)
|
||||
{
|
||||
if ($this->connect()) {
|
||||
|
|
|
@ -25,7 +25,8 @@ class iredis
|
|||
public function __construct()
|
||||
{
|
||||
$this->redis = new redis();
|
||||
$this->redis->pconnect($this->redis_server, $this->redis_port);
|
||||
$this->redis->connect($this->redis_server, $this->redis_port);
|
||||
## $this->redis->pconnect($this->redis_server, $this->redis_port);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
|
@ -58,6 +59,11 @@ class iredis
|
|||
{
|
||||
$this->redis->close();
|
||||
}
|
||||
|
||||
public function select($database=0)
|
||||
{
|
||||
$this->redis->select($database);
|
||||
}
|
||||
|
||||
public function append($key, $value)
|
||||
{
|
||||
|
|
|
@ -29,9 +29,10 @@ class looptest
|
|||
$ops = new dbops();
|
||||
$ops->setTBname($tbname);
|
||||
$ops->setDBname($dbname);
|
||||
##$start=$i*rand(1,950); # more then 2w
|
||||
$start=$i*128;
|
||||
$conditions = sprintf("idx > %d and idx < %d;",
|
||||
$start, $start + 1000);
|
||||
$conditions = sprintf ("idx > %d and idx < %d;",
|
||||
$start, $start+1000);
|
||||
$sql = sprintf("select * from %s where %s",
|
||||
$tbname, $conditions);
|
||||
$data = $ops->query($sql);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#require_once('mysql_info.php');
|
||||
require_once('dbops.php');
|
||||
require_once('iredis.php');
|
||||
|
||||
echo "数据库测试页面\n <br/>";
|
||||
date_default_timezone_set('PRC');
|
||||
|
@ -60,10 +61,11 @@ echo "<br/>";
|
|||
echo "<br/>";
|
||||
|
||||
echo "follow test redis:";
|
||||
$redis = new redis();
|
||||
$result = $redis->connect('127.0.0.1', 6379);
|
||||
$redis = new iredis();
|
||||
$result = $redis->configure('127.0.0.1', 6379);
|
||||
#var_dump($result); //结果:bool(true)
|
||||
$redis->set('test', 'hello world!');
|
||||
#$redis->set('test', 'hello world!');
|
||||
#$redis->select(1);
|
||||
echo $redis->get('test');
|
||||
|
||||
?>
|
||||
|
|
|
@ -24,7 +24,6 @@ class mysql2redis
|
|||
public function __construct()
|
||||
{
|
||||
$this->iredis = new iredis();
|
||||
|
||||
$this->mysql = new dbops();
|
||||
}
|
||||
|
||||
|
@ -34,15 +33,23 @@ class mysql2redis
|
|||
$this->mysql->close();
|
||||
}
|
||||
|
||||
public function tabsize($tabname)
|
||||
{
|
||||
$sql = sprintf("select idx, count(idx) as total from %s", $tabname);
|
||||
$rs=$this->mysql->tabsize($sql);
|
||||
$no=$rs->fetch_row();
|
||||
return $no[1];
|
||||
}
|
||||
|
||||
public function bench($items_number, $bench='bench')
|
||||
{ ## 测试前创建数据表格操作
|
||||
## $del_sql = sprintf("delete from %s where idx>0;", $bench);
|
||||
## $del_sql = sprintf("delete from %s where idx>0;", $bench);
|
||||
$del_sql = sprintf("delete from %s;", $bench);
|
||||
$this->mysql->query($del_sql);
|
||||
## $this->mysql->query("select * from bench;");
|
||||
## $this->mysql->query("select * from bench;");
|
||||
for ($i=0; $i < $items_number; $i++)
|
||||
{
|
||||
$value = sprintf("(%d,\"name%d\",\"%s\")", $i, $i, $bench);
|
||||
$value = sprintf("(%d,%d,\"name%d\",\"%s\")", $i, $i+1, $i, $bench);
|
||||
$insert_sql = sprintf("insert into %s values%s;",$bench,$value);
|
||||
$this->mysql->query($insert_sql);
|
||||
}
|
||||
|
|
|
@ -10,21 +10,26 @@ require_once('looptest.php');
|
|||
|
||||
#$tbname="account";
|
||||
#$tbname="temp";
|
||||
$tbname="bench_no_index";
|
||||
#$tbname="bench_no_index";
|
||||
#$tbname="bench";
|
||||
$dbname="test";
|
||||
$loop_times=10;
|
||||
$items_number=30000;
|
||||
$loop_times=20;
|
||||
|
||||
$tab_redis = new mysql2redis();
|
||||
$tab_redis->setTBname($tbname);
|
||||
$tab_redis->setDBname($dbname);
|
||||
# $tab_redis->bench($items_number, $tbname); ## 创建数据表格
|
||||
|
||||
$sql = sprintf("select * from %s where idx > 29000 and idx < 30000", $tbname);
|
||||
$startI=9000; ## 29000
|
||||
$endI=10000; ## 30000
|
||||
$sql = sprintf("select * from %s where idx > %d and idx < %d", $tbname, $startI, $endI);
|
||||
$tab_redis->mysql2redis($tbname, $sql);
|
||||
|
||||
######### 下面为测试调用
|
||||
echo "</br>";
|
||||
echo $sql;
|
||||
echo "</br>";
|
||||
|
||||
$lptest = new looptest();
|
||||
$lptest->configure($tbname, $dbname);
|
||||
|
||||
|
@ -41,13 +46,15 @@ echo "<br/>"; echo "<br/>";
|
|||
echo "[redis对应表".$tbname." ]执行 $loop_times 次循环(单次时间 ms)为:";
|
||||
echo ($rstime/$loop_times)*1000;
|
||||
|
||||
$items_number = $tab_redis->tabsize($tbname);
|
||||
|
||||
echo "<br/>"; echo "<br/>";
|
||||
echo "item=$items_number [数据库]/[redis]比值为:";
|
||||
echo $dbtime/$rstime;
|
||||
|
||||
######### 下面为测试输出
|
||||
|
||||
#$tab_redis->print_mysql_table();
|
||||
#$tab_redis->print_mysql_table($tbname);
|
||||
# var_dump($data);
|
||||
|
||||
?>
|
||||
|
|
|
@ -4,16 +4,18 @@ DROP TABLE IF EXISTS bench_no_index;
|
|||
|
||||
CREATE TABLE bench (
|
||||
idx INT(10) NOT NULL PRIMARY KEY,
|
||||
age INT(10),
|
||||
name VARCHAR(20) NOT NULL,
|
||||
des VARCHAR(100) NOT NULL
|
||||
);
|
||||
|
||||
insert into bench value(0,'000','shanghai');
|
||||
insert into bench value(0,0,'000','shanghai');
|
||||
|
||||
CREATE TABLE bench_no_index (
|
||||
idx INT(10) NOT NULL,
|
||||
age INT(10),
|
||||
name VARCHAR(20) NOT NULL,
|
||||
des VARCHAR(100) NOT NULL
|
||||
);
|
||||
insert into bench_no_index value(0,'000','shanghai');
|
||||
insert into bench_no_index value(0,0,'000','shanghai');
|
||||
|
||||
|
|
Loading…
Reference in New Issue