3 ms·
I'm trying to figure out what piece of the puzzle I'm missing. I converted the script to java, using apache's RandomStringUtils.randomAscii, and I get: With St
by killface 14y ago
I'm trying to figure out what piece of the puzzle I'm missing. I converted the script to java, using apache's RandomStringUtils.randomAscii, and I get:
With StringBuilder: 2.61 seconds
With String Concat: 3.03 seconds
I have to assume there's another loop running these, but I'm not seeing it. Each dictionary has 1 million elements at the end.
I just implemented it inside a junit test, here's the class:
http://pastebin.com/sFZjA1p2 http://pastebin.com/sFZjA1p2
Turns out java performance isn't bad at all.
EDIT:
I'm a dumbass, was converting nanos to full seconds. Post has been edited.
- ajanuary 14y agoThe C# version has the overhead of looking up the Encoding and creating a byte array each character. This can be avoided by using the libraries correctly.
- ajanuary 14y agoStrangely your StringBuilder version seems to really slow down for me at around iteration 6000000. If I replace the repeated use of uuid.toString with `String uuidStr = uuid.toString()` it works fine. Looks like the performance of toString differs between versions.