应读者哀求,本文将连续进行VB6与其它编程措辞的字符串拼接速率的测试。下面将进行Perl、Julia的字符串速率拼接测试,如有不敷之处请指出,将予以改动。为担保测试结果的公正,以下测试都是Release模式,32位优先,命令行(管理员身份)办法调用。
Perl拼接测试测试代码
#!/usr/bin/perl -w
(图片来自网络侵删)use Time::HiRes qw( gettimeofday );
my ($seconds, $microseconds) = gettimeofday;
$starttime=$seconds1000+(0.0+ $microseconds)/1000.0;
$strout = "";
for($a=0;$a<10000000;$a+=1){
$strout.="AAAAA";
}
#print("strout = $strout\n");
my ($e_seconds, $e_microseconds) = gettimeofday;
$endtime=$e_seconds1000+(0.0+ $e_microseconds)/1000.0;
printf "拼接一千万字符共用时%.0f毫秒\n",$endtime-$starttime;
测试结果
耗时822毫秒
Julia拼接测试 using Dates
using Printf
# 得到打算机当前韶光
starttime = Dates.now()
arrStr=[]
for i in 1:10000001
append!(arrStr,"AAAAA")
end
str1=join(arrStr,"")
# 获取过段韶光后的韶光
endtime = Dates.now()
# 打算韶光差并以豪秒的格式输出
delta = endtime - starttime
totaltime=Dates.value(delta)
@printf("拼接1千万字符串花费韶光:%d毫秒",totaltime)
测试结果
耗时4376毫秒
测试结果汇总 拼接性能排行榜
措辞
时长
C++ char
11毫秒
C
16毫秒
RUST
32毫秒
C++
75毫秒
Go
87毫秒
Lazarus
146毫秒
Delphi XE 10
156毫秒
C++ Builder2010
168毫秒
VB.Net
174毫秒
.Net7
183毫秒
C#
184毫秒
.NetCore3.1
185毫秒
Delph10 StringBuilder
188毫秒
Java8
196毫秒
VB6 system.text.V2.dll
248毫秒
IE JS
297毫秒
VisualFreeBasic永芳版
344毫秒
VB6 system.text.dll
346毫秒
Delphi7 FastMM4
549毫秒
Chrome JS
781毫秒
Perl
822毫秒
Excel VBA数组
844毫秒
twinBasic
856毫秒
Delphi7
889毫秒
VB6数组
949毫秒
Python3.11
1012毫秒
Python
1137毫秒
PHP
2156毫秒
Asp
3140毫秒
Julia
4376毫秒
VB6原始方法
未知