Currently I have a chunk of code in one of my apps that isn't thread-safe, so I have mutex locks around all the calls to it. I suspect that this is a significant bottle neck, but before I try to rewrite or replace it (it's not my code) I'd like to make sure.
Is there any reason I can't make several copies of this function, each with a different name (ie. func() -> func_1(), func_2(), func_3()...). I could then pass the threads a paramter when they are initialized that tells them which version to use (and make sure each version is only used by a single thread).
It'd bloat the code a bit, but it should give me a feel for how much that lock contention is costing me, right?
Is there any reason I can't make several copies of this function, each with a different name (ie. func() -> func_1(), func_2(), func_3()...). I could then pass the threads a paramter when they are initialized that tells them which version to use (and make sure each version is only used by a single thread).
It'd bloat the code a bit, but it should give me a feel for how much that lock contention is costing me, right?
