CodingAssembling

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  THERE IS NO GOD BUT (RENDLE)  
 To:  ALL
33530.1 
I've spent the day writing C# code which generates functions dynamically using MSIL, which is basically assembler for .NET. It's doing my head in, but it's fucking powerful.

There are two types of creationist: morons and liars.
0/0
 Reply   Quote More 

 From:  DarkBadger  
 To:  THERE IS NO GOD BUT (RENDLE)     
33530.2 In reply to 33530.1 
10010110001011001001111010100101 lol
0/0
 Reply   Quote More 

 From:  Rowan  
 To:  THERE IS NO GOD BUT (RENDLE)     
33530.3 In reply to 33530.1 
I can think of no good reason for doing that. Although I think I'd prefer it to the evil VB6 I've been doing today.
0/0
 Reply   Quote More 

 From:  THERE IS NO GOD BUT (RENDLE)  
 To:  Rowan     
33530.4 In reply to 33530.3 
It's much faster than using reflection. I'm writing a business object library which provides a feature allowing end users to specify default values for any string property. For example, MailingLabelName could default to Title + Initials + Surname. Dynamically accessing properties using reflection every time a property is changed is horrible. But using the System.Reflection.Emit namespace, I can dynamically generate methods based on the user settings, and assign them to event handlers on the objects, which means all the complex processing only has to be done once. It's awesome. I love .NET.

There are two types of creationist: morons and liars.
0/0
 Reply   Quote More 

 From:  Rich  
 To:  THERE IS NO GOD BUT (RENDLE)     
33530.5 In reply to 33530.4 

In a test in last month's 'sprint' we tested an emitted-code version of our business logic layer which currently uses reflection. On an enormous dataset, we got an operation that took 52 seconds, down to 2 seconds.

 

Emitted code is immense.


Rich - e - w - m
0/0
 Reply   Quote More 

 From:  THERE IS NO GOD BUT (RENDLE)  
 To:  Rich     
33530.6 In reply to 33530.5 

Cool. Apparently a lot of the base classes use emitted code for dynamic operations, like data binding and such.

 

Do you know whether lots of event handlers are a bad thing? Like, if I've got business objects with 20 properties each, would it be better to have a PropertyChanging event for each property, or one for the entire business object and the handling method does conditionals? Obviously the events would be exposed by the containing collections rather than the individual business objects, cos some of them can have hundreds of records and you don't want twenty thousand event handlers. I'm leaning towards separate events for each property.

 

Got a huge performance increase today by sticking individual data access routines in ThreadPool.QueueUserWorkItem calls. Be even better when ParallelFX gets released...


There are two types of creationist: morons and liars.
0/0
 Reply   Quote More 

 From:  Rich  
 To:  THERE IS NO GOD BUT (RENDLE)     
33530.7 In reply to 33530.6 

Odd you should mention that about the events. During our tests with the emitted code, we noticed that some events were being thrown about 25 million times, something we've not really done any analysis on before. Even so, with all those events flying, we saw that 50 sec reduction on a 52 second operation.

 

I'll let you know more if I can, once we've finished testing.


Rich - e - w - m
0/0
 Reply   Quote More 

 From:  THERE IS NO GOD BUT (RENDLE)  
 To:  Rich     
33530.8 In reply to 33530.7 
Are you using System.Data.DataSet? The ColumnChanged and RowChanged events on those seem to fire lots. If they're your own objects and events, try using get/set accessors on the event to prevent the same handler being added multiple times.

There are two types of creationist: morons and liars.
0/0
 Reply   Quote More 

Reply to All    
 

1–8

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats