本帖最后由 bylove 于 2023-9-14 18:07 编辑
VB.net | Sub Main() | | Dim t# = 0, max = 100000000, arr%() | | ReDim arr%(max) | | For j% = 1 To 5 | | t = Environment.TickCount | | For i% = 0 To max - 1 | | arr(i) = i | | Next | | Console.WriteLine(((Environment.TickCount - t) / 1000).ToString("0.00s")) | | Next | | Console.ReadKey(1) | | End SubCOPY |
0.52s
0.41s
0.31s
0.30s
0.33s
C# | static void Main(string[] args) | | { | | int max = 100000000; | | int[] arr = new int[max]; | | for (int j = 0; j < 5; j++) | | { | | double t = Environment.TickCount; | | for (int i = 0; i < max; i++) | | { | | arr[i] = i; | | } | | Console.WriteLine(((Environment.TickCount - t) / 1000).ToString("0.00s")); | | } | | Console.ReadKey(true); | | }COPY |
0.44s
0.31s
0.34s
0.36s
0.27s
PowerShell和c#从时间上来看差异也不大啊都是net上的方法
只能解释可能是由于PowerShell是解释型语言所以速度比vba还要慢了吧?
但是慢的也太多了吧?
这个就不谈了,怎么解释Object速度比int快呢?不应该是反过来吗? |