apache - What is the most efficient way to generate a UUID in PHP? -


is there significant overhead (cpu, memory and/or io) in making repeat calls following function:

public function getuuid() {     return `uuidgen -r`; # -r = version 4 } 

versus using all php implementation of generating uuid (v4)? if matters project using apache (prefork mpm) 2.2.22 , php 5.3.10 (with apc).

my initial feeling benefit of doing generation of uuid in c library instead of in php more make system call overhead. additionally uuidgen being part of util-linux package inherently trust more php library generate uuids correctly, i'm keen input.

i'd suggest profile problem. shell_exec() php function spawns shell, might not come cheap think. php class mention seems call subprocesses. did tests (on os x) , generate 10.000 uuids php class in minute, opposed 40 seconds shell_exec('uuidgen').

the php class seems call ifconfig in addition shell_exec(), might reason bigger overhead.

also results vary hash algorithm choose.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -