I was handed over a repository on github, https://github.com/ReneKroon/ttlcache having a ttlcache in which i fixed multiple bugs as i was running into them in app i am now maintaining at work. Im mainly interested in better or different test cases. I identified that the benchmarks are only single threaded for example, but am looking for more tips to improve. Share your thoughts!
评论:
jeffrallen:
RwKroon:Here's a totally random thing I noticed while taking a quick look:
https://github.com/ReneKroon/ttlcache/blob/master/priority_queue_test.go#L26
Checking types should be done with a type assertion, not with %T. Checkign with %T is slower, and also would break in a confusing way if the code was refactored. (If the code was refactored, a type assertion would likely immediately not compile, because the type would not exist anymore.)
-jeff
I will fix it.
