Hi
I was testing a quicksort algorithm.
long startTime = DateTime.Now.Ti cks; //ticks before sorting begins
q_sort( 0, mElements.Lengt h-1 );
TimeSpan tp =new TimeSpan((DateT ime.Now.Ticks - startTime)); //difference of
ticks
mSortTime = tp.TotalMillise conds; //sort time in milliseconds
Still, it alwasy returns 0.0
But other algorithms returns a valid value.
However, there is a positive difference between the ticks too.
I can't understand why it is behaving like this. Btw, sorting
works in a different thread.
Any insight?
rgds
KK 2 2423
your code worked fine for me, but i rewrote it for clarity.
static void Main(string[] args) {
DateTime startTime = DateTime.Now; //before sorting begins
Thread.Sleep(10 0); //simulate the sort
DateTime endTime = DateTime.Now; //after the sort
TimeSpan ts = endTime - startTime; //time difference
double mSortTime = ts.Milliseconds ; //sort time in milliseconds
Console.WriteLi ne(mSortTime);
}
KK wrote: Hi
I was testing a quicksort algorithm.
long startTime = DateTime.Now.Ti cks; //ticks before sorting begins
q_sort( 0, mElements.Lengt h-1 );
TimeSpan tp =new TimeSpan((DateT ime.Now.Ticks - startTime)); //difference of ticks
mSortTime = tp.TotalMillise conds; //sort time in milliseconds
Still, it alwasy returns 0.0
But other algorithms returns a valid value.
However, there is a positive difference between the ticks too.
I can't understand why it is behaving like this. Btw, sorting works in a different thread.
Any insight?
rgds KK
Umm, maybe this is either too obvious, or I'm wrong, but at the end of the
OP, KK said the sort runs in a different thread... Maybe
TimeSpan tp =new TimeSpan((DateT ime.Now.Ticks - startTime));
is called before the sorting actually starts in the *other* thread?
Just an idea,
Scott
"KK" <KK.kk.com> wrote in message
news:uK******** ******@TK2MSFTN GP12.phx.gbl... Hi
I was testing a quicksort algorithm.
long startTime = DateTime.Now.Ti cks; //ticks before sorting begins
q_sort( 0, mElements.Lengt h-1 );
TimeSpan tp =new TimeSpan((DateT ime.Now.Ticks - startTime)); //difference of ticks
mSortTime = tp.TotalMillise conds; //sort time in milliseconds
Still, it alwasy returns 0.0
But other algorithms returns a valid value.
However, there is a positive difference between the ticks too.
I can't understand why it is behaving like this. Btw, sorting works in a different thread.
Any insight?
rgds KK
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ThunderMusic |
last post by:
Hi,
I'm using the timespan's Parse method to build my timespan from a
string. here's the line I use :
m_Delay.Parse(RegKey.GetValue("Delay", "01:00:00"))
the value I get from the RegKey is 00:00:30, so it should give a timespan of
30 seconds, but when I do msgbox(m_Delay.ToString), it displays 00:00:00.
Am I doing something wrong?
|
by: Rosanne |
last post by:
I'm sure there's an easy solution to this that I am just not thinkin
of. I am trying to get the total minutes between 2 times. It work
fine except when the ending time crosses over midnight. For instance
I am trying to get the total minutes between 11:59 PM and 12:09 AM.
The subtract method on the TimeSpan object returns a crazy negativ
number. I can't seem to find a work around.
Thanks so much in advance!
--
|
by: Larry Bird |
last post by:
I want to use TimeSpan to determine the differences between two date to
include time. My input data is in the following format:
12/25/2004 12:23:00 AM or 01/05/2005 11:59:00 PM
How do I get TimeSpan to accept my input?
How do I get the difference between two dates using TimeSpan?
I want to have the results expressed in days, hours, minutes and seconds.
|
by: DWalker |
last post by:
In Visual Studio (Visual Basic) .NET 2002, I noticed that this:
Dim Elapsed as DateTime = Now - Now
gives a "compile time" error (error in the IDE), saying that the '-'
operator is not defined for the Date datatype. On the other hand,
Dim Elapsed as DateTime = Now + Now
does not give a compile time error but it thinks you're trying to
|
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 - startTime)); //difference of
ticks
| |
by: sd00 |
last post by:
Hi all, can someone give me some coding help with a problem that
*should* be really simple, yet I'm struggling with.
I need the difference between 2 times (Target / Actual)
However, these times will fall somewhere between a Start & End time
Further more, there will be Break & Lunch times between Start & End.
Example...
Start 08:00
Break start 10:30
|
by: Rob Meade |
last post by:
Hi all,
I'm having a bit of trouble with the following function....
Private Function GetSystemUpTime() As TimeSpan
' declare variables
Dim Result As TimeSpan
Dim PerformanceCounter As PerformanceCounter
|
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:
***************************************************************************************************************
{
...........................
PrintTimeSpanProblem();
device = new Device(0, DeviceType.Hardware, this,
CreateFlags.SoftwareVertexProcessing, presentParams);
PrintTimeSpanProblem();
|
by: shapper |
last post by:
Hello,
I have the following:
boxStat = new BoxStat {
BoxCount = database.Boxes.Count(),
SinceLastCreate = (DateTime.Now - database.Boxes.Max(b =>
b.CreatedAt)).Days ?? 0
};
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |