您的位置:首页 > 其它

Julia: SSD条件下读CSV的速度

2015-11-19 18:11 204 查看
_
_       _ _(_)_     |  A fresh approach to technical computing
(_)     | (_) (_)    |  Documentation: http://docs.julialang.org _ _   _| |_  __ _   |  Type "?help" for help.
| | | | | | |/ _` |  |
| | |_| | | | (_| |  |  Version 0.5.0-dev+566 (2015-10-01 22:40 UTC)
_/ |\__'_|_|_|\__'_|  |  Commit fdde0bd (48 days old master)
|__/                   |  x86_64-w64-mingw32


最近在SSD下测了一下读取CSV的速度:具体如下

一、6.5万行的CSV文件

julia> for i =1:3
println("第  $(i)  文件::")
name =string("C:\\Users\\Desktop\\MD",i,".csv")
@time kk =readcsv(name)
end
第  1  文件::
0.864097 seconds (2.69 M allocations: 89.255 MB, 2.69% gc time)
第  2  文件::
0.465881 seconds (2.1 M allocations: 66.335 MB, 24.58% gc time)
第  3  文件::
0.446851 seconds (2.1 M allocations: 66.335 MB)


其中,上面三个CSV文件约6.5万行,有9行的数据。如果按这个速度,差不多一秒有14万左右的速度。

二、在60万行CSV

我把上面的文件内容复制到近60万,再试一下读取的速度。

julia> for i =1:3
println("第  $(i)  文件::")
name =string("C:\\Users\\Desktop\\MD",i,".csv")
@time kk =readcsv(name)
end
第  1  文件::
4.041549 seconds (19.00 M allocations: 596.777 MB, 11.94% gc time)
第  2  文件::
4.677666 seconds (19.00 M allocations: 596.789 MB, 29.21% gc time)
第  3  文件::
5.182393 seconds (19.00 M allocations: 596.789 MB, 33.03% gc time)


可以看出,这个速度基本上还是比较线性的,差不多为1秒14万-15万行左右。

顺便提一下,读CSV的速度与CSV文件中的内容是isnumber,还是字符串,基本没影响。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: