diff options
Diffstat (limited to 'zen/guid.h')
-rwxr-xr-x | zen/guid.h | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -20,9 +20,11 @@ namespace zen inline std::string generateGUID() //creates a 16-byte GUID { - boost::uuids::uuid nativeRep = boost::uuids::random_generator()(); - //generator is only thread-safe like an int, so we keep it local until we need to optimize perf - //perf: generator: 0.22ms per call; retrieve GUID: 0.12µs per call + //perf: generator: 0.38ms per creation; + // retrieve GUID: 0.13µs per call + //generator is only thread-safe like an int => keep thread-local + thread_local boost::uuids::random_generator gen; + const boost::uuids::uuid nativeRep = gen(); return std::string(nativeRep.begin(), nativeRep.end()); } } |