Click here to Skip to main content
15,881,413 members
Home / Discussions / C#
   

C#

 
AnswerRe: Refactoring versus Performance Pin
Bernhard Hiller14-Jul-14 20:36
Bernhard Hiller14-Jul-14 20:36 
GeneralRe: Refactoring versus Performance Pin
Agent__00714-Jul-14 20:55
professionalAgent__00714-Jul-14 20:55 
AnswerRe: Refactoring versus Performance Pin
Kornfeld Eliyahu Peter14-Jul-14 21:35
professionalKornfeld Eliyahu Peter14-Jul-14 21:35 
GeneralRe: Refactoring versus Performance Pin
Agent__00714-Jul-14 21:49
professionalAgent__00714-Jul-14 21:49 
GeneralRe: Refactoring versus Performance Pin
OriginalGriff14-Jul-14 21:49
mveOriginalGriff14-Jul-14 21:49 
AnswerRe: Refactoring versus Performance Pin
OriginalGriff14-Jul-14 21:03
mveOriginalGriff14-Jul-14 21:03 
GeneralRe: Refactoring versus Performance Pin
Agent__00714-Jul-14 21:45
professionalAgent__00714-Jul-14 21:45 
GeneralRe: Refactoring versus Performance Pin
Rob Philpott14-Jul-14 21:48
Rob Philpott14-Jul-14 21:48 
Slightly off-topic but I was working on a little additive synthesis hobby application recently where I needed to sum together hundreds of sine waves 48,000 times a second. I spent quite a while getting it as fast as I could.

First observation is that computers are really blood quick these days.
Obviously Math.Sin was too slow so used a wavetable.
Floats were too slow so used 32-bit signed integers (this seems to vary by processor quite a lot)
Arrays have bound checking so moved into the unsafe domain
Repeated the actual business code inside the loop (copy and paste) so less iterations needed (better setting to looping ratio + to avoid pipeline flushes on processor)

But, the killer improvement I got was not to use member variables in the loops. By copying member data to local variables, doing all the calculations with this then updating member variables from the locals at the end it speeded up several fold. I think this is because the locals were assigned to a register and didn't need to be written back and forth to memory continually.

I can't remember what the stats were but they were outstanding, perhaps something in the order of 50,000 oscillators at 48KHz.
Regards,
Rob Philpott.

GeneralRe: Refactoring versus Performance Pin
OriginalGriff14-Jul-14 21:53
mveOriginalGriff14-Jul-14 21:53 
GeneralRe: Refactoring versus Performance Pin
Rob Philpott14-Jul-14 22:12
Rob Philpott14-Jul-14 22:12 
GeneralRe: Refactoring versus Performance Pin
OriginalGriff14-Jul-14 22:45
mveOriginalGriff14-Jul-14 22:45 
GeneralRe: Refactoring versus Performance Pin
Rob Philpott14-Jul-14 22:54
Rob Philpott14-Jul-14 22:54 
GeneralRe: Refactoring versus Performance Pin
Rob Philpott14-Jul-14 22:28
Rob Philpott14-Jul-14 22:28 
GeneralRe: Refactoring versus Performance Pin
OriginalGriff14-Jul-14 22:38
mveOriginalGriff14-Jul-14 22:38 
GeneralRe: Refactoring versus Performance Pin
Agent__00714-Jul-14 22:14
professionalAgent__00714-Jul-14 22:14 
GeneralRe: Refactoring versus Performance Pin
Rob Philpott14-Jul-14 22:18
Rob Philpott14-Jul-14 22:18 
GeneralRe: Refactoring versus Performance Pin
Agent__00714-Jul-14 22:24
professionalAgent__00714-Jul-14 22:24 
GeneralRe: Refactoring versus Performance Pin
Rob Philpott14-Jul-14 22:31
Rob Philpott14-Jul-14 22:31 
GeneralRe: Refactoring versus Performance Pin
Agent__00714-Jul-14 22:33
professionalAgent__00714-Jul-14 22:33 
AnswerRe: Refactoring versus Performance Pin
Pete O'Hanlon15-Jul-14 3:45
mvePete O'Hanlon15-Jul-14 3:45 
GeneralRe: Refactoring versus Performance Pin
Agent__00715-Jul-14 4:29
professionalAgent__00715-Jul-14 4:29 
GeneralRe: Refactoring versus Performance Pin
Pete O'Hanlon15-Jul-14 4:32
mvePete O'Hanlon15-Jul-14 4:32 
GeneralRe: Refactoring versus Performance Pin
Agent__00715-Jul-14 4:35
professionalAgent__00715-Jul-14 4:35 
AnswerRe: Refactoring versus Performance Pin
Joe Woodbury15-Jul-14 9:14
professionalJoe Woodbury15-Jul-14 9:14 
Questionremove labels X628 personnel in c # Pin
Member 971624414-Jul-14 14:12
Member 971624414-Jul-14 14:12 

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.