$cast performance

Hi,
I wonder what is the price of using $cast(destination, source) on structs.
Suppose I’m using it a lot in my simulation (10K+) - what is the effect? can it be measured by profiler?

What exactly does it do - creates and clones the source object into destination -
or something else?

Thanks!

In reply to Net:

There is no good reason to use $cast on anything other than class variables or enum encodings that require dynamic type checking. There might be a corner case for using $cast on other types when the variable’s types are parameterized and you want your code to work regardless of whether the types are assignment compatible or not. In that case the return value of $cast would be a constant. For assignment compatible types, 1’b1 gets returned and the assignment happens like a regular blocking assignment. For assignment incompatible types, 1’b0 gets returned and no assignment happens.

$cast never clones—it just copies the value in the source variable to the destination variable. In the case of a class object, it just copies the class handle.

In reply to dave_59:

Dave, thanks for your propounded response, as always.
I know why cast is used for - I just wanted to check about it’s performance.
How much time (in CPU) it takes and if it’s measurable by profiler or not.
I’ll try to test it out.