Question Events processing performance.

mbb

Well-known member
Joined
Jun 3, 2009
Messages
52
Programming Experience
10+
I was considering writing a timer object that periodically raises events in its own thread.

Lets say I have 70,000+ objects handling the timer's event.

I wanted to know what kind of performance overhead to expect in handling the events, besides the business specific code written into the handler?
 
I doubt anyone could tell you because I doubt anyone has done something quite that silly before. :) Would you care to provide a bit more information because I very much doubt that having that many objects handling the same event is the best way to go.
 
I doubt anyone could tell you because I doubt anyone has done something quite that silly before. :) Would you care to provide a bit more information because I very much doubt that having that many objects handling the same event is the best way to go.

Thanks for the reply.

I am working on a game engine and I am generating say 70,000 characters, probably more.

So, from the timer (which is really a calendar as the days go forward) a day, end of week, end of month and end of year events will be raised. In simplistic terms each character may or may not respond to the event raised and do some action if something is required.

I had it in mind to write a test program with this scenario and take a look at the impact on the OS anyway.

But I think you have confirmed my suspicions that this is probably not the way to go. I have seen a scheduler implemented in C# before, I think I'll put my thinking cap on and do something like that - using a command pattern.

Even so, I know I am going to be doing a lot behind the scenes processing on this game, its unavoidable. And if it cannot perform on current platforms I am going to have to go back to my PM and discuss some simplifications.

In the meantime, can you think of any better way than a scheduler?
 
Well, my test program of 70,000 objects listening for an event didn't break .NET, Windows or my program :cool:

There doesn't seem to be a memory overhead, but it shouldn't really have been a surprise to learn that my CPU's went up to 100% :rolleyes:

I'd imagine if there was any serious processing behind the events then gradually the whole system would grind to a halt, whilst it tried to process it's backlog of unprocessed events and handlers.

I'll find some time over the weekend to post up my code for prosperity.
 
Last edited:
Back
Top