My favorites
|
Sign in
qqwry
围绕纯真数据库开发的一系列小工具
Project Home
Downloads
Wiki
Issues
Source
Checkout
|
Browse
|
Changes
|
‹r18
r30
Source path:
svn
/
trunk
/
php
/
qqwry
/
test.php
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
if ($_SERVER['argc']<3) {
usage();
}
define('QQWRY_PATH',$_SERVER['argv'][1]);
if (!file_exists($_SERVER['argv'][1])) {
usage();
}
//tow implementations in native php language,
//used them to compare and test extension
require $_SERVER['argv'][2];
$arr=array();
for ($i=0;$i<500;$i++) {
$arr[]=rand(0,255).'.'.rand(0,255).'.'.rand(0,255).'.'.rand(0,255);
}
$qqwry=new qqwry(QQWRY_PATH);
$coolcode=new IpLocation(QQWRY_PATH);
initConvertIp(QQWRY_PATH);
echo "效率测试开始 ... ";
$times=array();
$t=microtime(true);
foreach ($arr as $ip) {
convertip($ip);
}
$times[0]=microtime(true)-$t;
$t=microtime(true);
foreach ($arr as $ip) {
$coolcode->getlocation($ip);
}
$times[1]=microtime(true)-$t;
$t=microtime(true);
foreach ($arr as $ip) {
$qqwry->q($ip);
}
$times[2]=microtime(true)-$t;
echo "测试结束\n";
echo '是discuz的',$times[0]/$times[2],"倍\n";
echo '是coolcode的',$times[1]/$times[2],"倍\n";
echo "正确性测试 ... ";
foreach ($arr as $ip) {
$s1=convertip($ip);
$s2=implode('',$coolcode->getlocation($ip));
$s3=implode('',$qqwry->q($ip));
if ($s3!=$s1 || $s3!=$s2) {
echo $ip,"\n";
var_dump($s1);
var_dump($s2);
var_dump($s3);
echo "错误发生\n";
exit(1);
}
//echo '|';
//var_dump(qqwry($ip,'QQWry.Dat'));
//echo "\n";
}
echo "一切ok\n";
function usage() {
echo "php test.php QQWry.Dat libqqwry.php\n";
exit;
}
Show details
Hide details
Change log
r19
by surfchen on Nov 27, 2008
Diff
remove a var_dump
Go to:
/trunk/php/qqwry/test.php
Project members,
sign in
to write a code review
Older revisions
r18
by surfchen on Nov 25, 2008
Diff
add some comments
r17
by surfchen on Nov 25, 2008
Diff
add test.php
All revisions of this file
File info
Size: 1467 bytes, 69 lines
View raw file
Hosted by