在本机测试为什么go循环这么慢? 如下代码循环要6-8秒,但是同样的代码写成php只要0.009秒左右,我哪里操作不对吗?
GO:
func main() {
st := time.Now().Unix()
str := ""
for i := 0; i < 100000; i++ {
str += "hello" + strconv.Itoa(i)
}
fmt.Println(time.Now().Unix() - st)
}
PHP:
$t1 = microtime(true);
$str = '';
for ($i = 0; $i < 100000; ++$i) {
$str .= "hello" . (string)$i;
}
echo microtime(true) - $t1;