Click here to Skip to main content
15,899,825 members
Home / Discussions / C#
   

C#

 
QuestionMS ReportViewer LocalMode: Report item not linked to a dataset. Pin
el delo27-Dec-11 11:47
el delo27-Dec-11 11:47 
Questionusing ZedGraph + *.txt file Pin
housepl27-Dec-11 7:42
housepl27-Dec-11 7:42 
AnswerRe: using ZedGraph + *.txt file Pin
OriginalGriff27-Dec-11 8:19
mveOriginalGriff27-Dec-11 8:19 
GeneralRe: using ZedGraph + *.txt file Pin
housepl27-Dec-11 8:28
housepl27-Dec-11 8:28 
GeneralRe: using ZedGraph + *.txt file Pin
OriginalGriff27-Dec-11 8:30
mveOriginalGriff27-Dec-11 8:30 
QuestionUnsafe code safety question Pin
Lutosław27-Dec-11 4:47
Lutosław27-Dec-11 4:47 
AnswerRe: Unsafe code safety question Pin
harold aptroot27-Dec-11 5:01
harold aptroot27-Dec-11 5:01 
GeneralRe: Unsafe code safety question Pin
Lutosław27-Dec-11 5:40
Lutosław27-Dec-11 5:40 
Thank you!
What I actually wanted to do was to take fixed statements outside a loop. It's because I have discovered, that these statements bring an overhead and, therefore, a performance drop. So, I had an idea to "cache" pinned pointers but I couldn't use a fixed statement when outside a loop. Finally, here is a result:
/*(parameters)*/ string[] oldValues,
int oldCount = oldValues.Length;
GCHandle[] oldHandles = new GCHandle[oldCount];
for (int i = 0; i < oldCount; i++)
{
    oldHandles[i] = GCHandle.Alloc(oldValues[i], GCHandleType.Pinned);
}
// in an inner (inner) loop:
char* oldFix = oldHandles[i].AddrOfPinnedObject();
// instead of
fixed (char* oldFix = oldValues[i])

This brought about 1.5x performance increase, so it was worth. But still I'm not sure if it is correct (and is hard to detect experimentally due to unpredictability of GC).

Edit: fixed fixed code
Greetings - Jacek


modified 27-Dec-11 13:15pm.

GeneralRe: Unsafe code safety question Pin
harold aptroot27-Dec-11 6:04
harold aptroot27-Dec-11 6:04 
GeneralRe: Unsafe code safety question Pin
Lutosław27-Dec-11 6:55
Lutosław27-Dec-11 6:55 
GeneralRe: Unsafe code safety question Pin
harold aptroot27-Dec-11 7:08
harold aptroot27-Dec-11 7:08 
GeneralRe: Unsafe code safety question Pin
Lutosław27-Dec-11 7:16
Lutosław27-Dec-11 7:16 
GeneralRe: Unsafe code safety question Pin
Lutosław27-Dec-11 8:43
Lutosław27-Dec-11 8:43 
GeneralRe: Unsafe code safety question Pin
harold aptroot27-Dec-11 9:06
harold aptroot27-Dec-11 9:06 
GeneralRe: Unsafe code safety question Pin
PIEBALDconsult27-Dec-11 6:06
mvePIEBALDconsult27-Dec-11 6:06 
AnswerRe: Unsafe code safety question Pin
PIEBALDconsult27-Dec-11 5:01
mvePIEBALDconsult27-Dec-11 5:01 
GeneralRe: Unsafe code safety question Pin
Lutosław27-Dec-11 5:26
Lutosław27-Dec-11 5:26 
GeneralRe: Unsafe code safety question Pin
PIEBALDconsult27-Dec-11 5:28
mvePIEBALDconsult27-Dec-11 5:28 
AnswerRe: Unsafe code safety question Pin
jschell27-Dec-11 10:18
jschell27-Dec-11 10:18 
QuestionResizing Controls According to Forms' Size Pin
AmbiguousName27-Dec-11 2:15
AmbiguousName27-Dec-11 2:15 
AnswerRe: Resizing Controls According to Forms' Size Pin
PIEBALDconsult27-Dec-11 2:29
mvePIEBALDconsult27-Dec-11 2:29 
AnswerRe: Resizing Controls According to Forms' Size Pin
David C# Hobbyist.27-Dec-11 2:34
professionalDavid C# Hobbyist.27-Dec-11 2:34 
AnswerRe: Resizing Controls According to Forms' Size Pin
Shameel27-Dec-11 4:08
professionalShameel27-Dec-11 4:08 
AnswerRe: Resizing Controls According to Forms' Size Pin
BillWoodruff27-Dec-11 4:38
professionalBillWoodruff27-Dec-11 4:38 
GeneralRe: Resizing Controls According to Forms' Size Pin
Roger Wright27-Dec-11 20:58
professionalRoger Wright27-Dec-11 20:58 

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.