forked from ideawu/sim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
50 lines (41 loc) · 854 Bytes
/
test.php
File metadata and controls
50 lines (41 loc) · 854 Bytes
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
require_once(dirname(__FILE__) . '/sim.php');
$ip = '127.0.0.1';
$port = 8800;
$sim = new SimClient($ip, $port, -1);
$req = array(
'echo',
'你好',
"hello world!",
'[hi]',
array(
'a',
'中',
'国',
'b',
),
);
$total = 10000;
$stime = microtime(1);
for($i=0; $i<$total; $i++){
$s = sim_encode($req);
}
$speed = $total / (microtime(1) - $stime);
printf("encode speed: %d /s\n", $speed);
$s = sim_encode($req);
$stime = microtime(1);
for($i=0; $i<$total; $i++){
$req = sim_decode($s);
}
$speed = $total / (microtime(1) - $stime);
printf("decode speed: %d /s\n", $speed);
$total = 10000;
$stime = microtime(1);
for($i=0; $i<$total; $i++){
$sim->send($req);
$resp = $sim->recv();
}
$speed = $total / (microtime(1) - $stime);
printf("request speed: %d qps\n", $speed);
echo sim_encode($req) . "";
echo sim_encode($resp) . "";