@@ -148,6 +148,7 @@ def __init__(
148148 self .component = component
149149 self .init_js = init_js
150150
151+ @timed
151152 def render (self ):
152153 response = super ().render ()
153154
@@ -157,7 +158,6 @@ def render(self):
157158 content = response .content .decode ("utf-8" )
158159
159160 frontend_context_variables = self .component .get_frontend_context_variables ()
160-
161161 frontend_context_variables_dict = orjson .loads (frontend_context_variables )
162162 checksum = generate_checksum (orjson .dumps (frontend_context_variables_dict ))
163163
@@ -253,6 +253,7 @@ def __init__(self, **kwargs):
253253 self ._set_default_template_name ()
254254 self ._set_caches ()
255255
256+ @timed
256257 def _set_default_template_name (self ) -> None :
257258 """
258259 Sets a default template name based on component's name if necessary.
@@ -272,6 +273,7 @@ def _set_default_template_name(self) -> None:
272273 template_name = self .component_name .replace ("." , "/" )
273274 self .template_name = f"unicorn/{ template_name } .html"
274275
276+ @timed
275277 def _set_caches (self ) -> None :
276278 """
277279 Setup some initial "caches" to prevent Python from having to introspect
@@ -282,6 +284,7 @@ def _set_caches(self) -> None:
282284 self ._methods_cache = self ._methods ()
283285 self ._set_resettable_attributes_cache ()
284286
287+ @timed
285288 def reset (self ):
286289 for (
287290 attribute_name ,
@@ -337,6 +340,7 @@ def called(self, name, args):
337340 """
338341 pass
339342
343+ @timed
340344 def render (self , init_js = False ) -> str :
341345 """
342346 Renders a UnicornView component with the public properties available. Delegates to a
@@ -369,6 +373,7 @@ def render(self, init_js=False) -> str:
369373
370374 return rendered_component
371375
376+ @timed
372377 def get_frontend_context_variables (self ) -> str :
373378 """
374379 Get publicly available properties and output them in a string-encoded JSON object.
@@ -407,6 +412,7 @@ def get_frontend_context_variables(self) -> str:
407412
408413 return encoded_frontend_context_variables
409414
415+ @timed
410416 def _get_form (self , data ):
411417 if hasattr (self , "form_class" ):
412418 try :
@@ -417,6 +423,7 @@ def _get_form(self, data):
417423 except Exception as e :
418424 logger .exception (e )
419425
426+ @timed
420427 def get_context_data (self , ** kwargs ):
421428 """
422429 Overrides the standard `get_context_data` to add in publicly available
@@ -432,9 +439,11 @@ def get_context_data(self, **kwargs):
432439
433440 return context
434441
442+ @timed
435443 def is_valid (self , model_names : List = None ) -> bool :
436444 return len (self .validate (model_names ).keys ()) == 0
437445
446+ @timed
438447 def validate (self , model_names : List = None ) -> Dict :
439448 """
440449 Validates the data using the `form_class` set on the component.
@@ -481,6 +490,7 @@ def validate(self, model_names: List = None) -> Dict:
481490
482491 return self .errors
483492
493+ @timed
484494 def _attribute_names (self ) -> List [str ]:
485495 """
486496 Gets publicly available attribute names. Cached in `_attribute_names_cache`.
@@ -492,6 +502,7 @@ def _attribute_names(self) -> List[str]:
492502
493503 return attribute_names
494504
505+ @timed
495506 def _attributes (self ) -> Dict [str , Any ]:
496507 """
497508 Get publicly available attributes and their values from the component.
@@ -505,6 +516,7 @@ def _attributes(self) -> Dict[str, Any]:
505516
506517 return attributes
507518
519+ @timed
508520 def _set_property (self , name , value ):
509521 # Get the correct value type by using the form if it is available
510522 data = self ._attributes ()
@@ -535,6 +547,7 @@ def _set_property(self, name, value):
535547 f"'{ name } ' attribute on '{ self .component_name } ' component could not be set. Is it a @property without a setter?"
536548 )
537549
550+ @timed
538551 def _methods (self ) -> Dict [str , Callable ]:
539552 """
540553 Get publicly available method names and their functions from the component.
@@ -553,6 +566,7 @@ def _methods(self) -> Dict[str, Callable]:
553566
554567 return methods
555568
569+ @timed
556570 def _set_hook_methods_cache (self ) -> None :
557571 """
558572 Caches the updating/updated attribute function names defined on the component.
@@ -568,6 +582,7 @@ def _set_hook_methods_cache(self) -> None:
568582 if hasattr (self , function_name ):
569583 self ._hook_methods_cache .append (function_name )
570584
585+ @timed
571586 def _set_resettable_attributes_cache (self ) -> None :
572587 """
573588 Caches the attributes that are "resettable" in `_resettable_attributes_cache`.
0 commit comments