Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,868 questions

51,791 answers

573 users

How to measure time in milliseconds using VB.NET

2 Answers

0 votes
Imports System

Public Module DateTimeTools
    Private ReadOnly Jan1st1970 As System.DateTime = New System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc)

    Function CurrentUnixTimeMillis() As Long
        Return CLng((System.DateTime.UtcNow - Jan1st1970).TotalMilliseconds)
    End Function
End Module

Public Class TimeInMilliseconds
    Public Shared Sub Main(ByVal args As String())
        Dim startTime As Long = DateTimeTools.CurrentUnixTimeMillis()

        For i As Integer = 0 To 20000000 - 1
        Next

        Dim estimatedTime As Long = DateTimeTools.CurrentUnixTimeMillis() - startTime
	
        Console.WriteLine(estimatedTime)
    End Sub
End Class


' run:
'
' 31
'

 



answered Jun 28, 2024 by avibootz
0 votes
Imports System
Imports System.Diagnostics

Public Class TimeInMilliseconds
    Public Shared Sub Main(ByVal args As String())
        Dim stopwatch = New Stopwatch()
        stopwatch.Start()

        For i As Integer = 0 To 20000000 - 1
        Next

        stopwatch.Stop()
        
		Dim elapsed_time = stopwatch.ElapsedMilliseconds
        
		Console.WriteLine(elapsed_time)
    End Sub
End Class



' run:
'
' 34
'

 



answered Jun 28, 2024 by avibootz

Related questions

1 answer 107 views
1 answer 94 views
1 answer 107 views
1 answer 118 views
2 answers 153 views
1 answer 116 views
2 answers 139 views
139 views asked Jun 28, 2024 by avibootz
...