c# - What's faster: expression trees or manually emitting IL -


is there performance difference between creating method emitting il directly, opposed building expression tree?

ultimately, expression tree's api more familiar api on relection.emit , equivalent, though believe there many things cannot in expression trees can via direct reflection.emit.

reflection.emit fastest overall, in same way loop faster foreach in general. there many scenarios can write code executes faster using reflection.emit can using expression api, in cases should come out equivalent.

now, expression api lend being better way of doing things couple of reasons.

  1. it's composable in simpler way using direct reflection.emit. can take expression tree , re-write add in logic easier can using direct il
  2. optimizations may added in future may not understand not have occurred when using direction reflection.emit.

so ultimately, it's wash. if it's critical , know reflection.emit quite well, can take shortcuts in il won't using expression api, other that, in general usage, should equivalent.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -