/**
*
*
* 每个进程都单独连接数据库
* */
//configruation parameters
$tbl_id = 0;
$count_per_process = 10;
$concurrents = 100;
$logpath = "/tmp/s.log";
$host = "10.218.26.75";
$user = "user";
$pwd = "pwd";
$db = "test";
$port = 3306;
$sep = 1000;
$uid_count = 100000;
$uid_path= 100000;
if ($argc != 13) {
echo "Usage:php multiprocess.php tbl_id concurrents count_per_process logpath host user pwd db port sep_counts uid_count uid_path\n";
echo "Usage:php multiprocess.php 表ID 并发数 每进程多少次 记录路径 主机 用户 密码 数据库 端口 多少条记录一次 用户数 用户UID保存路径\n";
exit(1);
} else {
$tbl_id= trim($argv[1]);
$concurrents = (int)trim($argv[2]);
$count_per_process= (int)trim($argv[3]);
$logpath = trim($argv[4]);
$host = trim($argv[5]);
$user = trim($argv[6]);
$pwd = trim($argv[7]);
$db = trim($argv[8]);
$port = trim($argv[9]);
$sep = trim($argv[10]);
$uid_count= (int)trim($argv[11]);
$uid_path = trim($argv[12]);
if($uid_count < $concurrents and ($uid_count % $concurrents !=0 )) {
die("UID数必须多过并发进程数并曲uid数必须是进程数的整数倍\n");
}
$uid_count = $uid_count / $concurrents;
}
$shm_key = ftok(__FILE__, 't');
$shm_id = shmop_open($shm_key, "c", 0644, 100);
shmop_write($shm_id, 0, 0);
$m_start= microtime(true);
$conf = array(
'count' => $count_per_process,
'host' => $host,
'user' &#