c# - Performance of an IF statement on back-end versus view (razor) -


my project built on ms's mvc4 platform in c#.

i'm feeding view model represents row table in front-end, , have add if clause may turn row invalid, representation in table row filled '-' in of it's collumns.

in order fill view model have iterate through number of objects, , have once again in front-end place them correctly.

i want know, in terms of performance, faster:

1 - fill view model lots of '-', 1 each object iterated , iterate once again fill collumns same information.

2 - place boolean flag on viewmodel, indicating row invalid , consequently skiping iteration on back-end. when reach front-end ask flag, , in case it's true iterate trough collumns filling them.

i know may seem little bit obvious second option smarter, know code runs way faster in back-end in view, in case i'm confused.

p.s. know best way try it, have tasks before can test, , in case has experienced similar situation i'd glad hear results.

p.s.2 - hardly doubt case of question answer 'strictly based on opinion'

thanks in advance

on first test, code inside view (.cshtml) took 17 minutes rendered, not if clause, other calcs.

considering it's not big amount of data, performance huge disappointment. decided rewrite whole function in back-end view conceived to, show information 100% pre-calculated.

with processing in back-end, same action took 1 minute rendered.

lesson learned, not, or @ least, avoid max coding on view because it's performance awful.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -