472,958 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 6259
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: unified | last post by:
Ok, I'm working on a program that is supposed to compare each letter of a string that is put into a stack and a queue. It is supposed to tell whether or not a word is a palindrome or not. (a...
3
by: palm | last post by:
Hi I have a system.collection.queue object. One thread X enque objects into this queue and another thread Y dequeues object and process them. I want to add a listener for this queue in thread Y...
7
by: RobKinney1 | last post by:
Here is another question we have been meaning to post for a long time. My colleague is literally pulling chunks of hair out of his head right now. We have a logging class. This class is...
5
Rooro
by: Rooro | last post by:
Hello everyone i'm working on : " Familiar childhood games such as hide and Go Seek and Tag involve determining the player who is to be "It". One method has the players stand in a circle...
5
by: not_a_commie | last post by:
Using a synchronized Queue, I did some testing on catching the "queue was empty on dequeue" exception vs. doing my own lock, checking for empty, and then dequeuing. The try/catch method, though...
10
by: Craig Buchanan | last post by:
I would like to have a limited pool of objects (the objects are expensive to create) that can be enlisted to process items in a queue. Moreover, I would like to be able to have the processing...
1
by: VanKha | last post by:
I write a queue program but it doesn't work properly:I enqueue an element and dequeue just after that, but the output is the first value and then many times of "Empty queue.."!Why ?Please help me. ...
2
by: ecestd | last post by:
how do you implement a copy constructor for this pointer-based ADT queue #include <cassert // for assert #include <new // for bad_alloc using namespace std; //private:{Queue::Queue(const...
0
by: ecestd | last post by:
I did implement the copy constructor but still have a problem with it. It is not working. What could be wrong? #include "QueueP.h" #include <cassert // for assert #include <new // for...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.