I've creating a new encryption algorithm. Its totally unbreakable and extremely fast. I call it ROT-13. Now I want to do some benchmark tests on it to prove my speed. However I don't just want to encrypt and decrypt the same plaintext over and over, because that will lead to branch prediction that wouldn't happen in reality; instead I want to generate some random plaintext outside the measured function and inject it in.
I thought I could do something like
public class Rot13Benchmark{
public String plaintext;
@Setup(Level.invocation)
public void setup(){
plaintext = randomString();
}
@Benchmark
public String rot13Benchmark(){
return rot13(plaintext);
}
}
But according to the docs on Level.invocation -
WARNING: HERE BE DRAGONS!
...
This level is only usable for benchmarks that take more than a millisecond...
Since invocations of rot13 are not expected to take more than a millisecond, it doesn't seem like this is the right pick for me.
What is the correct way to provide random input to my benchmark function such that the random input generation time is not counted towards the benchmark?
Aucun commentaire:
Enregistrer un commentaire