Click here to Skip to main content
15,889,281 members
Home / Discussions / C#
   

C#

 
GeneralRe: Code optimization Pin
tvbarnard18-Oct-09 3:28
tvbarnard18-Oct-09 3:28 
GeneralRe: Code optimization Pin
Eddy Vluggen18-Oct-09 3:37
professionalEddy Vluggen18-Oct-09 3:37 
GeneralRe: Code optimization Pin
tvbarnard18-Oct-09 3:52
tvbarnard18-Oct-09 3:52 
GeneralRe: Code optimization Pin
Luc Pattyn19-Oct-09 4:21
sitebuilderLuc Pattyn19-Oct-09 4:21 
GeneralRe: Code optimization Pin
tvbarnard19-Oct-09 5:09
tvbarnard19-Oct-09 5:09 
GeneralRe: Code optimization Pin
Luc Pattyn19-Oct-09 5:37
sitebuilderLuc Pattyn19-Oct-09 5:37 
GeneralRe: Code optimization Pin
tvbarnard19-Oct-09 6:02
tvbarnard19-Oct-09 6:02 
GeneralRe: Code optimization Pin
Luc Pattyn19-Oct-09 6:40
sitebuilderLuc Pattyn19-Oct-09 6:40 
tvbarnard wrote:
some of the stuff you've said I've already done


Now getting good performance is very similar to getting correct results: you may theoretically improve one aspect (fix one bottleneck or one bug) but still not reach the final goal. That does not mean the step you made was right or wrong, it only says you haven't reached the finish yet.

In your case, if you don't need double, don't use them unless comfort (not sure which) is more important than performance. If you apply a sufficient number of optimizations, you will see the improvement; one by one they may not be noticeable or effective at all. That does not mean you should apply them all at once, apply them one by one, make sure it still works correctly, and move on until the goal has been reached (again, same as debugging).

Answers:

1. if using negative indexes for negPoints, that would require code similar to this:
int index=points[i];
if (index>0) value+=data[index];
else value-=data[-index-1];


2.
I did not imply merging the classifiers, only merge their point arrays. So the classifiers continue to exist, except they now hold a start and an end index into the new overall points array, instead of their own posPoints array. Them having a double errorRate doesn't change a thing.

3.
I haven't looked into the official parallel package in any detail. What I mean in principle is this:
let each thread perform its job on its part of the data, and store results in its own variables (one could use "thread local data" for it); then sum all the thread results. This avoids a continuous data contention when all threads would try and increment a single counter. As I said, I don't know how that maps on Parallel.For at all. Anyway unless they did a very good job, I wouldn't use it; what you really need is split the data in N and create N threads, where N is the number of concurrent threads your hardware supports (probably the number of cores).

Smile | :)

Luc Pattyn

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages

Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.


GeneralRe: Code optimization Pin
tvbarnard19-Oct-09 6:55
tvbarnard19-Oct-09 6:55 
GeneralRe: Code optimization Pin
Luc Pattyn19-Oct-09 7:06
sitebuilderLuc Pattyn19-Oct-09 7:06 
GeneralRe: Code optimization Pin
tvbarnard19-Oct-09 7:41
tvbarnard19-Oct-09 7:41 
GeneralRe: Code optimization Pin
Luc Pattyn19-Oct-09 12:45
sitebuilderLuc Pattyn19-Oct-09 12:45 
AnswerRe: Code optimization Pin
tvbarnard20-Oct-09 1:33
tvbarnard20-Oct-09 1:33 
GeneralRe: Code optimization Pin
Luc Pattyn20-Oct-09 1:40
sitebuilderLuc Pattyn20-Oct-09 1:40 
GeneralRe: Code optimization Pin
tvbarnard20-Oct-09 6:50
tvbarnard20-Oct-09 6:50 
GeneralRe: Code optimization Pin
Luc Pattyn20-Oct-09 6:53
sitebuilderLuc Pattyn20-Oct-09 6:53 
GeneralRe: Code optimization Pin
tvbarnard20-Oct-09 6:55
tvbarnard20-Oct-09 6:55 
GeneralRe: Code optimization Pin
Luc Pattyn18-Oct-09 11:24
sitebuilderLuc Pattyn18-Oct-09 11:24 
GeneralRe: Code optimization Pin
tvbarnard18-Oct-09 22:37
tvbarnard18-Oct-09 22:37 
GeneralRe: Code optimization Pin
Luc Pattyn19-Oct-09 4:27
sitebuilderLuc Pattyn19-Oct-09 4:27 
GeneralRe: Code optimization Pin
tvbarnard19-Oct-09 4:42
tvbarnard19-Oct-09 4:42 
GeneralRe: Code optimization Pin
tvbarnard18-Oct-09 3:31
tvbarnard18-Oct-09 3:31 
AnswerRe: Code optimization Pin
Not Active18-Oct-09 3:30
mentorNot Active18-Oct-09 3:30 
GeneralRe: Code optimization Pin
tvbarnard18-Oct-09 3:36
tvbarnard18-Oct-09 3:36 
GeneralRe: Code optimization Pin
Not Active18-Oct-09 3:53
mentorNot Active18-Oct-09 3:53 

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.