$start = microtime(true);
$num = 1000;
$step = 10000;
$count = $step * $num;
for ($i = 0; $i < $num; $i++) {
$items = [];
for ($j = 0; $j < $step; $j++) {
$items[] = [
'name' => uniqid(),
'created' => Carbon::now()->format('Y-m-d H:i:s'),
];
}
Db::table('users')->insert($items);
}
$end = microtime(true);
$output->writeln("insert " . $count/10000 . "w, use " . round($end - $start, 2) . 's');
如上代碼,用webman開命令行 10個(gè)進(jìn)程一起跑
寫1億條數(shù)據(jù),用了大概12分鐘
查詢的時(shí)候比較奇怪,用DB Browser for SQLite查詢,count總條數(shù)耗時(shí)大概3秒,用webman反而只耗時(shí)1s