Array Performance Test: Two-dimensional Array and SetValue(i, i) : Array Multi Dimension « Data Structure « VB.Net






Array Performance Test: Two-dimensional Array and SetValue(i, i)

Array Performance Test: Two-dimensional Array and SetValue(i, i)
 
Imports System
Imports System.Collections

Public Class MainClass
    
    Shared Sub Main(ByVal args As String())
        Dim start_time As DateTime
        Dim stop_time As DateTime
        Dim elapsed_time As TimeSpan

        ' Get the number of items.
        Dim num_items As Integer = 1000000

        ' Two-dimensional Array.
        Dim array4 As Array = _
            Array.CreateInstance(GetType(Integer), 1, num_items)
        start_time = Now
        For i As Integer = 0 To num_items - 1
            array4.SetValue(i, 0, i)
        Next i
        stop_time = Now
        elapsed_time = stop_time.Subtract(start_time)
        Console.WriteLine( elapsed_time.TotalSeconds().ToString )


    End Sub

End Class
  

           
         
  








Related examples in the same category

1.Initializing a jagged array, one in which the length of each array differsInitializing a jagged array, one in which the length of each array differs
2.Define and initialize the multi-dimensional arrayDefine and initialize the multi-dimensional array
3.Seclare a 4x3 Integer arraySeclare a 4x3 Integer array
4.Array Performance Test: Two-dimensional arrayArray Performance Test: Two-dimensional array
5.Two Dimensional Rectangle ArrayTwo Dimensional Rectangle Array
6.Define and Init two dimensional arrayDefine and Init two dimensional array
7.Initializing multidimensional arrays: rectangular two-dimensional arrayInitializing multidimensional arrays: rectangular two-dimensional array
8.Jagged two-dimensional arrayJagged two-dimensional array
9.Two dimension array DemoTwo dimension array Demo
10.Array.SetValue for two-dimensional array
11.Array.SetValue for three-dimensional array
12.Array.SetValue for a seven-dimensional array
13.Clear multi-dimensional array