473,792 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculate processing time.

Hello,

I do:

Debug.WriteLine ("A: " & DateTime.Now.Ti cks.ToString)
REM Calculate a bunch of stuff. Some loops and math functions.
Debug.WriteLine ("B: " & DateTime.Now.Ti cks.ToString)

but both A and B have the exact the same value. Is this method incorrect?
When I make the function wait for 1 millisecond, A en B differ. Is there
another way to calculate the processing time? Without looping the stuff a
100 times and then devide the result by 100.

Thanks.
Dec 12 '05 #1
4 6229
>
Debug.WriteLine ("A: " & DateTime.Now.Ti cks.ToString)
REM Calculate a bunch of stuff. Some loops and math functions.
Debug.WriteLine ("B: " & DateTime.Now.Ti cks.ToString)

but both A and B have the exact the same value. Is this method incorrect?
When I make the function wait for 1 millisecond, A en B differ. Is there
another way to calculate the processing time? Without looping the stuff a
100 times and then devide the result by 100.


I would prefer doing it 100 or even more times, to make sure you get an
accurate timing.

The first time you run a routine the CLR might do some optimizing that
actually makes it run slower the first few times.

/Søren Reinke
Dec 12 '05 #2
"Qwert" <no**@nosp.co m> schrieb
Hello,

I do:

Debug.WriteLine ("A: " & DateTime.Now.Ti cks.ToString)
REM Calculate a bunch of stuff. Some loops and math functions.
Debug.WriteLine ("B: " & DateTime.Now.Ti cks.ToString)

but both A and B have the exact the same value. Is this method
incorrect? When I make the function wait for 1 millisecond, A en B
differ. Is there another way to calculate the processing time?
Without looping the stuff a 100 times and then devide the result by
100.

In addition to Søren, the resolution of DateTime.Now is too low to measure
things. Use Environment.Tic kcount (returns milliseconds) instead or a high
performance counter (in VB 2005, you can use System.Diagnost ics.Stopwatch)

See also:
http://groups.google.com/group/micro...7a1a5c8d980072

(especially post #4ff ;-)

Armin

Dec 12 '05 #3
"Qwert" <no**@nosp.co m> schrieb:
Debug.WriteLine ("A: " & DateTime.Now.Ti cks.ToString)
REM Calculate a bunch of stuff. Some loops and math functions.
Debug.WriteLine ("B: " & DateTime.Now.Ti cks.ToString)

but both A and B have the exact the same value. Is this method incorrect?


You may want to use this timer:

<URL:http://www.mentalis.or g/soft/class.qpx?id=8>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 12 '05 #4
Great, thanks all.

That 'QueryPerforman ceCounter' and 'QueryPerforman ceFrequency' code of
mentalis did the trick. None of the .NET functionality I could find was
precise enough (fastest time was 0,0003 seconds).

Don't have VB2005 yet, so I couldn't try "in VB 2005, you can use
System.Diagnost ics.Stopwatch". I did try:

Dim objProcessorTim e As New System.Diagnost ics.Performance Counter()
objProcessorTim e.CategoryName = "Processor"
objProcessorTim e.CounterName = "% Processor Time"
objProcessorTim e.InstanceName = "_Total"

but wasn't precise enough.

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> schreef in bericht
news:OI******** ******@tk2msftn gp13.phx.gbl...
"Qwert" <no**@nosp.co m> schrieb:
Debug.WriteLine ("A: " & DateTime.Now.Ti cks.ToString)
REM Calculate a bunch of stuff. Some loops and math functions.
Debug.WriteLine ("B: " & DateTime.Now.Ti cks.ToString)

but both A and B have the exact the same value. Is this method incorrect?


You may want to use this timer:

<URL:http://www.mentalis.or g/soft/class.qpx?id=8>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
5748
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
1
13606
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number Name 1200hr 1700hr 1900hr 2200hr 1200hr 1700hr 1900hr 2200hr ============================================================================ 4654 Saniff A A A C A A A C 4437 Joey B C B C B C B C 4479 Elmer C C B C C C B C
7
16089
by: Tim Quon | last post by:
Hi Is there any function to get the current time so I can calculate the execution time of my code? What all is in the time.h and sys/times.h? Thanks Tim
6
5000
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a PDF. It works fine so far....
5
6520
by: cvisal | last post by:
Hi all Im working on productivity calculations (Time calculations) and need some help in coding. Database Tool:MS-Access 2003. The general operator punch-in time is 5:30 AM and the punch-out time is 2:00PM. The Break times are 1) 9:30 AM to 9:45 AM 2) 11:00AM to 11:30 AM 3) 12:30PM to 12:45 PM
2
7931
by: cylin | last post by:
Hi, I am currently doing a project regarding image processing. I had facing problem writing C++ code to calculate time taken to execute a function. Can somebody help me on this. thanks. #include "picture.h" #include <iostream> using namespace std; int main()
4
3020
by: NormAmst | last post by:
I have a list of CPU processing times and job durations for an entire department at work. There are 3 classifications I am maintaining. CPU time during peak hours , CPU time during non peak hours and total CPU time. I developed an Excel spreadsheet totaling the times and manually format a spreadsheet to present total jobs run and total CPU time for the department. I also developed an Access 2002 db, where I import all the run job...
2
2124
by: Lancelot | last post by:
Hello everyone. This is my first post here, but I've been looking for answer many time. I have a crazy idea in my head and since I am quite a newby to python, I am not sure where to start or if it's evenly possible. I wonder if you can calculate the time of respond of a wireless system to evaluate the distance of this device from the computer. I tought of a wireless mouse. Is there a even that you can send, check the local time, wait...
6
4100
by: rrstudio2 | last post by:
I am using the following vba code to calculate the median of a table in MS Access: Public Function MedianOfRst(RstName As String, fldName As String) As Double 'This function will calculate the median of a recordset. The field must be a number value. Dim MedianTemp As Double Dim RstOrig As Recordset Set RstOrig = CurrentDb.OpenRecordset(RstName, dbOpenDynaset)
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10159
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.