Click here to Skip to main content
15,886,258 members
Home / Discussions / C#
   

C#

 
SuggestionRe: Rx SubscribeOn and ObserveOn Pin
Matt T Heffron25-Feb-16 10:26
professionalMatt T Heffron25-Feb-16 10:26 
GeneralRe: Rx SubscribeOn and ObserveOn Pin
Kenneth Haugland25-Feb-16 10:33
mvaKenneth Haugland25-Feb-16 10:33 
GeneralRe: Rx SubscribeOn and ObserveOn Pin
Kenneth Haugland25-Feb-16 20:27
mvaKenneth Haugland25-Feb-16 20:27 
AnswerRe: Rx SubscribeOn and ObserveOn Pin
Matt T Heffron26-Feb-16 7:20
professionalMatt T Heffron26-Feb-16 7:20 
GeneralRe: Rx SubscribeOn and ObserveOn Pin
Kenneth Haugland25-Feb-16 20:55
mvaKenneth Haugland25-Feb-16 20:55 
QuestionIssue with retrieving items from an IEnumerable<T> Pin
RichardGrimmer24-Feb-16 3:27
RichardGrimmer24-Feb-16 3:27 
SuggestionRe: Issue with retrieving items from an IEnumerable<T> Pin
Richard Deeming24-Feb-16 3:50
mveRichard Deeming24-Feb-16 3:50 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
RichardGrimmer24-Feb-16 4:23
RichardGrimmer24-Feb-16 4:23 
Hi Richard - many thanks for the quick reply...


Richard Deeming wrote:
Don't measure the performance of your code using DateTime; use the Stopwatch class[^] instead.

I'm not measuring the performance per-se, just getting an idea, and in any case that part of the code won't be in the prod version...


Richard Deeming wrote:
Did you make sure to "warm up" the code before you timed it, and run the test over many iterations?

Absolutely - same perf over many MANY runs Smile | :)
Richard Deeming wrote:
Since you know the maximum number of items you'll be adding to the list, you should set its capacity when you create it:
C#
List<object> entityBatch = new List<object>(batchSize);

If you don't set the capacity, it starts at 4 and doubles each time it runs out of space.

Valid point - made the change and no real effect - still around 12s

Richard Deeming wrote:
You need to check the value returned from enumerator.MoveNext; if it returns false, you've reached the end of the sequence. Your code currently continues adding the final items from the sequence to the list until you reach the batch size.

Again, valid point, but in this instance it's not the problem - I can be certain that it's not at the end.


Richard Deeming wrote:
You should consider using proper generic types, rather than a List<object>; that way, you avoid having to cast the items back to the correct type when you read the batches.

Also a valid point, but not possible in this instance - it's in an abstract base class, which operates over several types of similar but not related types and exists in a (necessarily) singleton class....my thinking is leading me to the point that it may well be an area to look at, but given that IEnumerator.Current returns an object type anyway I'm not sure.
Richard Deeming wrote:
It's probably best to wrap this sort of thing up as a extension method

Ultimately that's a possibility, but until I can bottom out the cause of the several orders of magnitude difference it's sort of neither here or there - appreciate the comment however.

Many thanks again - I'll have to keep digging into it and see what's what!
C# has already designed away most of the tedium of C++.

GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
Richard Deeming24-Feb-16 4:34
mveRichard Deeming24-Feb-16 4:34 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
RichardGrimmer24-Feb-16 4:44
RichardGrimmer24-Feb-16 4:44 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
Pete O'Hanlon24-Feb-16 5:06
mvePete O'Hanlon24-Feb-16 5:06 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
RichardGrimmer24-Feb-16 5:34
RichardGrimmer24-Feb-16 5:34 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
RichardGrimmer24-Feb-16 20:15
RichardGrimmer24-Feb-16 20:15 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
Pete O'Hanlon24-Feb-16 22:09
mvePete O'Hanlon24-Feb-16 22:09 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
RichardGrimmer26-Feb-16 4:28
RichardGrimmer26-Feb-16 4:28 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
RichardGrimmer24-Feb-16 20:16
RichardGrimmer24-Feb-16 20:16 
QuestionCapture a image fram from a local video using a button to transfer into a picturebox and then save into local disk in C#.NET Pin
Member 1209982523-Feb-16 20:57
Member 1209982523-Feb-16 20:57 
AnswerRe: Capture a image fram from a local video using a button to transfer into a picturebox and then save into local disk in C#.NET Pin
Pete O'Hanlon23-Feb-16 21:23
mvePete O'Hanlon23-Feb-16 21:23 
GeneralRe: Capture a image fram from a local video using a button to transfer into a picturebox and then save into local disk in C#.NET Pin
Richard MacCutchan24-Feb-16 1:16
mveRichard MacCutchan24-Feb-16 1:16 
AnswerRe: Capture a image fram from a local video using a button to transfer into a picturebox and then save into local disk in C#.NET Pin
Gerry Schmitz24-Feb-16 6:57
mveGerry Schmitz24-Feb-16 6:57 
QuestionDispose of RX subscriptions Pin
Kenneth Haugland23-Feb-16 2:28
mvaKenneth Haugland23-Feb-16 2:28 
AnswerRe: Dispose of RX subscriptions Pin
Kenneth Haugland23-Feb-16 2:32
mvaKenneth Haugland23-Feb-16 2:32 
Questionhello guys I have a problem in my string cmd.... Pin
Member 1217509322-Feb-16 22:59
Member 1217509322-Feb-16 22:59 
AnswerRe: hello guys I have a problem in my string cmd.... Pin
Pete O'Hanlon22-Feb-16 23:41
mvePete O'Hanlon22-Feb-16 23:41 
AnswerRe: hello guys I have a problem in my string cmd.... Pin
OriginalGriff22-Feb-16 23:52
mveOriginalGriff22-Feb-16 23:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.