471,319 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Queue.Dequeue () slow?

It's currently taking a minimum of .2 seconds for me to dequeue an
object - I'm wondering if it's the dequeue that is taking so long or if
it's just the fact that i'm doing it like this:

retMsg = (ServerMessage)s_messages.Dequeue();

is there a faster way?
Dec 9 '05 #1
4 6037
Benny Raymond <be***@pocketrocks.com> wrote:
It's currently taking a minimum of .2 seconds for me to dequeue an
object - I'm wondering if it's the dequeue that is taking so long or if
it's just the fact that i'm doing it like this:

retMsg = (ServerMessage)s_messages.Dequeue();

is there a faster way?


That shouldn't take very long at all. Are you absolutely sure that line
is the issue?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 9 '05 #2
I wrote up an example program with my ServerMessage and it ran
instantly.. :( The thing is, however, in my main program I put the
following lines before and after the dequeue:

Debug.WriteLine("START DQ: " + DateTime.Now.ToString("mm:ss.fffffff"));
ServerMessage m = (ServerMessage)myQueue.Dequeue();
Debug.WriteLine("END DQ: " + DateTime.Now.ToString("mm:ss.fffffff"));

I know it's a pretty bad way to look at how long things take, but that's
how I got the .2+ second mark... Not sure why it's doing that in my main
program but not the sample one... in the sample one the time between
start and end doesn't change at all.

Jon Skeet [C# MVP] wrote:
Benny Raymond <be***@pocketrocks.com> wrote:
It's currently taking a minimum of .2 seconds for me to dequeue an
object - I'm wondering if it's the dequeue that is taking so long or if
it's just the fact that i'm doing it like this:

retMsg = (ServerMessage)s_messages.Dequeue();

is there a faster way?

That shouldn't take very long at all. Are you absolutely sure that line
is the issue?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Dec 9 '05 #3
Benny Raymond wrote:
I wrote up an example program with my ServerMessage and it ran
instantly.. :( The thing is, however, in my main program I put the
following lines before and after the dequeue:

Debug.WriteLine("START DQ: " + DateTime.Now.ToString("mm:ss.fffffff"));
ServerMessage m = (ServerMessage)myQueue.Dequeue();
Debug.WriteLine("END DQ: " + DateTime.Now.ToString("mm:ss.fffffff"));

I know it's a pretty bad way to look at how long things take, but that's
how I got the .2+ second mark... Not sure why it's doing that in my main
program but not the sample one... in the sample one the time between
start and end doesn't change at all.


In your main program, is anything else happening at the same time? For
instance, is myQueue synchronized, and is something else is locking on
it?

Jon

Dec 9 '05 #4
Yep... that's exactly what was happening - I ended up finding a huge
flaw with the way I had originally designed the class. I designed it to
run in 3 threads (two of which needed that queue) when I could have done
everything in 2 threads and made the entire process around 15 times
faster, and an infinite amount of times safer! So that's what i'll be
doing this weekend... re-writing code from what i've learned ;)

~Benny

Jon Skeet [C# MVP] wrote:
Benny Raymond wrote:
I wrote up an example program with my ServerMessage and it ran
instantly.. :( The thing is, however, in my main program I put the
following lines before and after the dequeue:

Debug.WriteLine("START DQ: " + DateTime.Now.ToString("mm:ss.fffffff"));
ServerMessage m = (ServerMessage)myQueue.Dequeue();
Debug.WriteLine("END DQ: " + DateTime.Now.ToString("mm:ss.fffffff"));

I know it's a pretty bad way to look at how long things take, but that's
how I got the .2+ second mark... Not sure why it's doing that in my main
program but not the sample one... in the sample one the time between
start and end doesn't change at all.

In your main program, is anything else happening at the same time? For
instance, is myQueue synchronized, and is something else is locking on
it?

Jon

Dec 9 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by unified | last post: by
3 posts views Thread by palm | last post: by
7 posts views Thread by RobKinney1 | last post: by
Rooro
5 posts views Thread by Rooro | last post: by
10 posts views Thread by Craig Buchanan | last post: by
1 post views Thread by VanKha | last post: by
reply views Thread by ecestd | last post: by
reply views Thread by rosydwin | last post: by

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.