Measuring performance of Java UUID.fromString() (or lack thereof)

aka “Why is UUID.fromString() so slow?”

Background

UUID uuid = UUID.fromString(request.getParameter("uuid"));

#include <std-disclaimers.h>

Does JUG have it? How about Jackson?

UUID uid = UUIDUtil.uuid(uuidString);

Test Case & Results, initial

Benchmark                     Mode   Cnt      Score       Error  Units
UUIDFromString.m1_JDK thrpt 15 89175.229 ± 1899.754 ops/s
UUIDFromString.m2_JUG thrpt 15 490052.366 ± 35351.600 ops/s
UUIDFromString.m3_manual thrpt 15 1129569.239 ± 6054.405 ops/s

Results with JDK 14

Benchmark                 Mode   Cnt    Score       Error    Units
UUIDFromString.m1_JDK thrpt 15 358738.222 ± 7188.453 ops/s
UUIDFromString.m2_JUG thrpt 15 529761.948 ± 3866.240 ops/s
UUIDFromString.m3_manual thrpt 15 1181016.727 ± 4541.903 ops/s

Reasons for slowness of Java 8 / UUID.fromString()

Next Steps

Open Source developer, most known for Jackson data processor (nee “JSON library”), author of many, many other OSS libraries for Java, from ClassMate to Woodstox