上次改脚本,直接对标题进行正则:
https://vulsee.com/archives/vulsee_2021/1202_15790.html
后来发现未先对标题是否存在关键字进行判断,怀疑对性能有影响,在本地1.3W数据测试了下:
测试:
(1)未加标题判断:
<?php
// vuless.com
//连接数据库
$servername = "localhost";
$username = "root";
$password = "123456";
$dbname = "test";
// 创建连接
$conn = new mysqli($servername, $username, $password,$dbname);
// 检测连接
if ($conn->connect_error) {
die("连接失败: " . $conn->connect_error);
}
echo "连接成功"."<br>";
//读取数据
$t1=microtime(true);
$sql = "SELECT post_title FROM wp_posts";
$result = $conn->query($sql);
echo $result->num_rows;
while($row = $result->fetch_assoc()) {
$cve = strtoupper($row["post_title"]);
$res = stristr($cve, 'cve');
preg_match_all('/(CVE|cve|CNVD|cnvd)-[0-9]{0,}-[0-9]{0,}/', $cve, $matches);
$res = $matches[0];
if (count($res)>0){
echo "--------------".$res[0]."<br>";
}
}
echo "<br/>";
$t2 = microtime(true);
echo ($t2-$t1)*1000;
?>
读取耗时约:1520ms左右

(2)加标题判断:
<?php
//连接数据库
$servername = "localhost";
$username = "root";
$password = "123456";
$dbname = "test";
// 创建连接
$conn = new mysqli($servername, $username, $password,$dbname);
// 检测连接
if ($conn->connect_error) {
die("连接失败: " . $conn->connect_error);
}
echo "连接成功"."<br>";
//读取数据
$t1=microtime(true);
$sql = "SELECT post_title FROM wp_posts";
$result = $conn->query($sql);
echo $result->num_rows;
while($row = $result->fetch_assoc()) {
$cve = strtoupper($row["post_title"]);
$res = stristr($cve, 'cve');
if($res==true){
preg_match_all('/(CVE|cve|CNVD|cnvd)-[0-9]{0,}-[0-9]{0,}/', $cve, $matches);
$res = $matches[0];
if (count($res)>0){
echo "--------------".$res[0]."<br>";
}
}
}
echo "<br/>";
$t2 = microtime(true);
echo ($t2-$t1)*1000;
// vuless.com
?>
读取耗时约:1220ms左右

结论:
在处理大量数据的时候,效果还是笔记明显的,如果是单条数据,也大约有1-2ms的区别


![[python] 百度分词工具:lac测试以及paddle等 -- vulsee.com-微慑信息网-VulSee.com](https://vulsee.com/wp-content/uploads/2021/12/12b611d121dd28a2d5109d281efbd64a.png)
![[python] Arc90's readability.js -vulsee.com-微慑信息网-VulSee.com](https://vulsee.com/wp-content/uploads/2022/01/ee09885b4d9ed6b399ed5dead9727115.png)


![MySQL实时监控代码审计工具集合[更新]-微慑信息网-VulSee.com](http://vulsee.com/wp-content/uploads/2020/06/288.png)
![Nessus install [2018-11]-微慑信息网-VulSee.com](http://vulsee.com/wp-content/uploads/2020/06/159.png)




![[JAVA]16进制数据与class文件的相互转换测试-微慑信息网-VulSee.com](http://vulsee.com/wp-content/uploads/2020/01/479.png)

![[八卦] 王婷婷—揭秘一个大三女生的性爱录像-微慑信息网-VulSee.com](http://free.86hy.com/crack/pic/1.jpg)
![[随笔]今天国际警察节-微慑信息网-VulSee.com](http://photo.sohu.com/20041017/Img222528326.jpg)

青云网
