473,382 Members | 1,225 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

TimeSpan, Ticks

Hi, I want to measure a time (in ticks) between a couple of operations, with
these code:

long voor = DateTime.Now.TimeOfDay.Ticks;

bmp1 = new Bitmap(@"\Network\im\ImageWeftIllum.bmp");

bmp2 = new Bitmap(@"\Network\im\ImageWarpIllum.bmp");

g.DrawImage( bmp1, 0, 0 );

g.DrawImage( bmp2, 1, 1 );

long na = DateTime.Now.TimeOfDay.Ticks;;

na=na-voor;

textBoxTijd.Text=na.ToString()+" ticks";

The textBoxTijd only gives something like this: 2000 000 ticks or 3000 000
ticks, but never something like 3333 325, what's the problem? I also put
more operations between the measuring, but always some stuff like that: 2000
000 33 000 000, help me pleae

I debug on a Win CE 4.2

THX
Nov 15 '05 #1
4 4910
Jeroen CEuppens <je*************@barco.com> wrote:
Hi, I want to measure a time (in ticks) between a couple of operations, with
these code:

long voor = DateTime.Now.TimeOfDay.Ticks;

bmp1 = new Bitmap(@"\Network\im\ImageWeftIllum.bmp");

bmp2 = new Bitmap(@"\Network\im\ImageWarpIllum.bmp");

g.DrawImage( bmp1, 0, 0 );

g.DrawImage( bmp2, 1, 1 );

long na = DateTime.Now.TimeOfDay.Ticks;;

na=na-voor;

textBoxTijd.Text=na.ToString()+" ticks";
Firstly, I'd just use:

DateTime voor = DateTime.Now;

....

DateTime na = DateTime.Now;

TimeSpan diff = na-voor;

and then use the results of that. However...
The textBoxTijd only gives something like this: 2000 000 ticks or 3000 000
ticks, but never something like 3333 325, what's the problem? I also put
more operations between the measuring, but always some stuff like that: 2000
000 33 000 000, help me pleae I debug on a Win CE 4.2


The Pocket PC timer is very coarse - ie it doesn't update very often. I
suspect you would still see multiples of ticks even on a desktop
system, but with a Pocket PC it'll be more pronounced.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
If you need high precision timing i recommend you use the
QueryPerformanceCounter and QueryPerformanceFrequency that is in
kernel32.dll

Just wrap these (there is a KB article on MSDN for this) and call them.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP***********************@msnews.microsoft.co m...
Jeroen CEuppens <je*************@barco.com> wrote:
Hi, I want to measure a time (in ticks) between a couple of operations, with these code:

long voor = DateTime.Now.TimeOfDay.Ticks;

bmp1 = new Bitmap(@"\Network\im\ImageWeftIllum.bmp");

bmp2 = new Bitmap(@"\Network\im\ImageWarpIllum.bmp");

g.DrawImage( bmp1, 0, 0 );

g.DrawImage( bmp2, 1, 1 );

long na = DateTime.Now.TimeOfDay.Ticks;;

na=na-voor;

textBoxTijd.Text=na.ToString()+" ticks";


Firstly, I'd just use:

DateTime voor = DateTime.Now;

...

DateTime na = DateTime.Now;

TimeSpan diff = na-voor;

and then use the results of that. However...
The textBoxTijd only gives something like this: 2000 000 ticks or 3000 000 ticks, but never something like 3333 325, what's the problem? I also put
more operations between the measuring, but always some stuff like that: 2000 000 33 000 000, help me pleae

I debug on a Win CE 4.2


The Pocket PC timer is very coarse - ie it doesn't update very often. I
suspect you would still see multiples of ticks even on a desktop
system, but with a Pocket PC it'll be more pronounced.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #3
Thx for info,

The Pocket PC timer is very coarse , idd, i check it, windows xp give me 33
ms or 33,750, but CE don't

I use this also, same result, nog good vision of the milliseconds :(
DateTime voor = DateTime.Now;

...

DateTime na = DateTime.Now;

TimeSpan diff = na-voor;

I hope the PerformanceCounter works to counts time for operations or do you
know any better way to counts time?

Thx
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP***********************@msnews.microsoft.co m... Jeroen CEuppens <je*************@barco.com> wrote:
Hi, I want to measure a time (in ticks) between a couple of operations, with these code:

long voor = DateTime.Now.TimeOfDay.Ticks;

bmp1 = new Bitmap(@"\Network\im\ImageWeftIllum.bmp");

bmp2 = new Bitmap(@"\Network\im\ImageWarpIllum.bmp");

g.DrawImage( bmp1, 0, 0 );

g.DrawImage( bmp2, 1, 1 );

long na = DateTime.Now.TimeOfDay.Ticks;;

na=na-voor;

textBoxTijd.Text=na.ToString()+" ticks";


Firstly, I'd just use:

DateTime voor = DateTime.Now;

...

DateTime na = DateTime.Now;

TimeSpan diff = na-voor;

and then use the results of that. However...
The textBoxTijd only gives something like this: 2000 000 ticks or 3000 000 ticks, but never something like 3333 325, what's the problem? I also put
more operations between the measuring, but always some stuff like that: 2000 000 33 000 000, help me pleae

I debug on a Win CE 4.2


The Pocket PC timer is very coarse - ie it doesn't update very often. I
suspect you would still see multiples of ticks even on a desktop
system, but with a Pocket PC it'll be more pronounced.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #4
Jeroen CEuppens <je*************@barco.com> wrote:
I hope the PerformanceCounter works to counts time for operations or do you
know any better way to counts time?


I don't, I'm afraid - I don't know whether that PerformanceCounter
exists on Pocket PC. I suggest you ask again in the compactframework
newsgroup - you may well get better answers.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #5

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

Similar topics

1
by: pete | last post by:
I need to take many TimeSpan values and find their average. I know you can Add the many values together, but how do you then divide that result by the count of values that you had? Once I have...
2
by: KK | last post by:
Hi I was testing a quicksort algorithm. long startTime = DateTime.Now.Ticks; //ticks before sorting begins q_sort( 0, mElements.Length-1 ); TimeSpan tp =new TimeSpan((DateTime.Now.Ticks -...
3
by: Ivan A. | last post by:
Hi! Why I can't serialize TimeSpan structure with XmlSerializer? This is what I do: using System; using System.IO; using System.Xml; using System.Xml.Serialization;
11
by: Russ Green | last post by:
How does this: public TimeSpan Timeout { get { return timeout; } set { timeout = value; if(timeout < licenseTimeout) licenseTimeout = timeout; }
2
by: ucasesoftware | last post by:
i translate a C# funtion to VB.NET and i have this : Shared Function isAllDay(ByVal ap As Appointment) As Boolean Return ap.DateBegin.TimeOfDay = TimeSpan.Zero AndAlso ap.DateEnd.TimeOfDay =...
3
by: Jeff Jarrell | last post by:
I am unable to add up two timespans as created by the System.Diagnostics.Stopwatch class. Each stopwatch should be about two seconds and is appears ok, but when I try and add them up it goes to...
5
by: Vibhesh | last post by:
I am facing problem with TimeSpan structure when DirectX is used. Following is the sample code that causes the problem: ...
4
by: kellygreer1 | last post by:
I haven't worked with the TimeSpan object before. So bare with me if this seems like a newb question. But if I wanted to know how many days from the current date until 2/4/2008. I have written...
2
by: Israel | last post by:
I've run across many situations where I want to store the time delta as a TimeSpan (e.g. sampling interval) and then I want to skip every 3rd sample so I want to multiple the delta by the int 3 but...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.