c# - Improving performance of Castle's DynamicProxy? -


i'm trying implement aop system add automatic audits decorated attributes of objects (done extended version of inotifypropertychanged). automatic audit contains propertyname it's old value , new value.

i'm using castle's dynamicproxy2 there excellent tutorials (namely one:: http://kozmic.pl/archive/2009/04/27/castle-dynamic-proxy-tutorial.aspx) on how use tool. generate delegate each property decorated type. expression tree generates this:: (note figure easier pasting expression tree code code relies on type-safe reflection library , lots of static variables)

.lambda #lambda1<system.action`1[castle.dynamicproxy.iinvocation]>(castle.dynamicproxy.iinvocation $invocation) {     .block(         dutchtest.mixintest $target,         system.object $argument,         system.datetime $newvalue,         system.datetime $oldvalue) {         $target = (dutchtest.mixintest).call $invocation.get_invocationtarget();         $newvalue = .unbox($argument = .call $invocation.getargumentvalue(.default(system.int32)));         .if (             .call (.call system.collections.generic.equalitycomparer`1[system.datetime].get_default()).equals(                 $oldvalue = .call $target.get_created(),                 $newvalue)         ) {             .default(system.void)         } .else {             .block() {                 .call $invocation.proceed();                 .call ($target .as dutch.auditing.inotifyauditedchange).onpropertychanged(.new dutch.auditing.auditeventargs(                         "created",                         (system.object)$oldvalue,                         $argument))             }         }     } } 

i have custom selector choses delegatedinterceptor (a class implements iinterceptor, intercept method invoke delegate. have custom hook chooses the properties plan on delegating (so avoid cost of proxying method).

unfortunately, these precautions looking @ substantial performance hit on every property set (it takes approximately .4 ticks logic hand , 2.2 ticks if dynamic proxy, 2.8 ticks if have mixin logic inotifyauditedchange , event raised). wouldn't bad, part of requirements looking @ large amount of objects being modified.

unfortunately, plans use typebuilder failed (it way hard write code reflection.emit , apparently compiletomethod cannot used instance methods), there tricks missing improve performance of dynamicproxy2?


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -