Jul 2, 2013 at 11:12 PM
Edited Jul 2, 2013 at 11:26 PM
Earlier we talked about removing the RestSharp dependency. I did some testing today, and I don't see any significant performance difference. Removing RestSharp does mean we'd need to add the Microsoft HttpClient Library (because HttpClient is included
in 4.5, but not 4.0 which we're targeting). I think it's better to have a dependency on a Microsoft package than a third-party one, but really, meh. I could go either way.
However, in my testing, I did notice that it's taking us a full minute to return a GetAllEvents response. I tested this in the main branch to make sure my async changes weren't doing it. The result (using a Release build):
Elapsed Time: 56745
Total Number of Events: 84277
If you go to your browser and you just type in
, the response comes back instantly. So why, when we do this in our code, does it take so long?
The answer is GwEvent.ResolveIDs(). It's spending that whole time resolving IDs and returning the new objects. This brought me back to the fact that GwEvent is a struct. I flipped it to a class, and this was the result:
Elapsed Time: 30673
Total Number of Events: 84272
It literally cut the time in half - just changing the word 'struct' to 'class', with no other changes.
Now, if we make it a class, then we also don't have to do ResolveIDs at all. We can just expose Map, Name, etc as property accessors that do the lookup. I changed the class to work like that, and this was the result:
Elapsed Time: 2640
Total Number of Events: 84318
So we're down from one minute to 2.6 seconds.
Please, please, can we stop using struct for events. The object is just too complicated. It's horrible for performance, and it's making our wrapper unusable for any high performance application.