Attach profiler via Proxy Pattern [5.3.0-B1]
Profiling is essential to ensure core In-Portal components keep doing their duties fast. Currently the profiler code is fused into some classes, like kFactory
or kTagProcessor
, which makes it problematic to easily locate all profiler-related code when needed.
Some components however, like kDBConnection
class have sub-classes (e.g. kDBConnectionDebug
, which only purpose is to add profiler code around some method calls.
Solution
Use polymorphism (sub-class classes that needs to be profiled on regular basis) instead of placing if ( $profiler.... ) {...
like IF statements in the code, that only slows it down in majority of cases. We can also create a marker IProfilerAware
interface to be used with these profiler-sub-classes to easily inject profiler instance (if any) in them during construction time.