我惊讶地发现Python在获取索引位置上比PHP慢。有没有方法可以提高Python的性能?在
例如:
用PHP计算:18.169965982437
<?php
$time_start = microtime(true);
$needle = file_get_contents("needle.wav", false, null, 46);
foreach(range(0, 10000) as $num) {
$haystack = file_get_contents("haystack.wav");
$match = strpos($haystack,$needle);
}
$time_end = microtime(true);
$finishTime = $time_end - $time_start;
echo $finishTime;
?>
在Python中,它需要:23.6319999695
^{pr2}$
等效的python代码如下:
相关问题 更多 >
编程相关推荐