dswitzer
04/23/2025, 9:28 PMisInstanceOf(), but this has huge performance impacts (I'm still on Lucee 5.4.6.9). See https://luceeserver.atlassian.net/browse/LDEV-4905 for details.
What's the fastest way to verify if a variable is an instance of a specific component?
The fastest method I've found so far is to use getMetaData() and check the component name, but I feel like there's still got to be a faster way.
Using isInstanceOf() the code I'm testing will take 15-30 seconds to run. Using getMetaData(), the time drops down < 1s.bdw429s
04/23/2025, 9:32 PMbdw429s
04/23/2025, 9:46 PMthis.className = getMetadata( this ).mame;
and then check it as
someInstance.className ?: ''bdw429s
04/23/2025, 9:46 PMdswitzer
04/24/2025, 10:42 AMisInstanceOf(). The code triggers the execution of it a few thousand times. The code is executed when evaluting how to hand processing some code being lazy loaded.zackster
04/24/2025, 1:12 PMzackster
04/24/2025, 1:15 PMgetMetaData()?zackster
04/24/2025, 1:17 PMdswitzer
04/24/2025, 1:22 PMgetMetaData() is much better than isInstanceOf(). Same exact code, using isInstanceOf() seems to average about 20-40ms per call, where as getMetaData() is < 2ms.
The problem with isInstanceOf() I think is do to the synchronization locks happening internally, as least that's what I've found before and documented in LDEV-4905.
I'm not sure why isInstanceOf() is so slow in these use cases. Perhaps it's because it's ultimately being triggered as part of a work flow that goes through a createDynamicProxy() call and might indeed be stuck doing some reflexion.dswitzer
04/24/2025, 1:24 PMisInstanceOf() with a simple isObject() call that checks for a specific method. That reduced a ton of overhead. Just weird that it's so slow.zackster
04/24/2025, 1:44 PMdswitzer
04/24/2025, 1:49 PMzackster
04/24/2025, 1:56 PMdswitzer
04/24/2025, 1:57 PMzackster
04/24/2025, 1:57 PMdswitzer
04/24/2025, 1:57 PMzackster
04/24/2025, 1:58 PMdswitzer
04/24/2025, 1:58 PMzackster
04/24/2025, 1:58 PMdswitzer
04/24/2025, 2:21 PMbdw429s
04/24/2025, 5:59 PMbdw429s
04/24/2025, 5:59 PM