title: Does a global object offer better performance than several local instances?
body: <p>I'm currently refactoring some c++ for a genetic programming system. In the current code, I have an random number generator object available globally. Its setup like this</p>
  
  <pre><code>RNG.h
  RNG.cpp   -&gt; Instance created here
  
  Globals.h -&gt; includes 'RNG.h'
            -&gt; extern RNG rng;
  
  OtherClasses -&gt; include 'Globals.h'
  </code></pre>
  
  <p>The RNG instance sets up a vector of generators, one for each available thread. I've spent time making this fast. This Global setup was convenient, but is this likely to be faster with an instance per translation unit? Is there a best practice around this sort of requirement?</p>
  
  <p>Its often said to remove globals where possible, but it seems to fit well here.</p>