Previous test efficiency test is conducted at swoole
https://www.cnblogs.com/fuyifan/p/11736784.html
The test directly in the nginx TP
for ($i = 0; $i < 1000; $i++) {
$tmp['name'] = 'f_'.$i;
$tmp['times'] = date('Y-m-d H:i:s');
db('task')->insert($tmp);
}
Or use the same code
Test results are as follows
0.778391s Normal DB ()
0.735788s persistent connection profile
0.684113s persistent connection DB () create a new object in an outer loop (the same operation should a single case table and in almost the same page)
$obj = db('task');
for ($i = 0; $i < 700; $i++) {
$tmp['name'] = 'f_'.$i;
$tmp['times'] = date('Y-m-d H:i:s');
$obj->insert($tmp);
}
Singleton Model 0.637927s
for ($i = 0; $i < 700; $i++) {
$tmp['name'] = 'f_'.$i;
$tmp['times'] = date('Y-m-d H:i:s');
TaskModel::insertOne($tmp['name'],$tmp['times']);
}
A comparison of the test results, the same data are found swoole insert 700 is performed inside the second 2.X
Under the direct nginx takes only seconds 0.x