|
Elwin Ho made changes - 08/Dec/06 11:57 PM
And this is using 1.4 release in java version. Elwin, it seems you are wrong. From the code snippet you show in the description, the variable is already declared static, and initialized in a static block. This means it is only created once per class-loader.
I think the UUID standard comprises several algorithms for building the identifiers. This would explain why there are more than one generator. Most of the generation time in SimpleUUIDGen is spent on random value generation. This is because it uses a SecureRandom instance, which is rather slow. I believe this class must not be changed too much, as the algorithm must be kept standard compliant. If you do not require secure random generation, you may better use the default one (FastUUIDGen, in the same package). I have tried to improve the execution time by moving some of the code to the static block, and optimizing some of the private methods. The times changed from 16000ms to 12000ms for 100 ids. This means an improvement of around 25%. I attach the patch for these changes.
Rodrigo Ruiz made changes - 24/Apr/07 11:17 AM
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Env.
PM 1.8 hz.
Java 1.4
2G memory.
long elwin_startTime = System.currentTimeMillis();
for (int i=0; i<10; i ++)
{
suuidg.nextUUID();
}
System.out.println("take "
+ ((System.currentTimeMillis()-elwin_startTime))
+ " ms");