12/27/2023 0 Comments Benchmark testing![]() So, here's the functional code as we left it in the last post (check there for more details on why it looks this way or what it's supposed to do):įunc Benchmark_generateString(b *testing. I had a hunch that we could improve the performance of the code, but first needed to write a benchmark so that we could tell as quickly as possible whether I was right. The way that the Go benchmark test works is that it tries to run your function as many times as possible within a second over and over with the same input, then spits out the results. While the Go testing tooling will run any other unit tests in the package by default, benchmark tests are not concerned with the question of whether or not your code does what you want it to, but rather simply how quickly it will run. This seemed like a place where we might be able to make a measurable performance optimization, and a good excuse to play with the benchmark testing capability built in to Go.Īs a bit of background, benchmark testing is basically just testing performance time. As I was working through the code changes, I noticed that I was creating a new random seed every time my function was called. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.Last month I wrote a post about testing a simple function to generate random strings using the testing/quick package in Go.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |