3 ms·
Well, it depends whether the time spent copying the bytes for the function invocation is less than the time spent garbage-collecting objects that are passed as
by echlebek 9y ago
Well, it depends whether the time spent copying the bytes for the function invocation is less than the time spent garbage-collecting objects that are passed as pointers, and then following those pointers. So as you can imagine, it's highly variable depending on the lifecycle of those objects, how frequently the function is being called, and probably a bunch of other factors like how big your CPU cache is. And then there is the cost of pointer indirection, which can cause cache misses.
I don't think there's really a rule of thumb here. Writing benchmarks, and observing the results is about the best you can do.