Closed picatz closed 6 years ago
Solid work!
I definitely like this
Great work.
Going to look over this once more (right now this morning) and then merge the new Result
struct. 👍
I'm going to add tests for the Printable()
, IsPrintable()
, Print()
, and JSON()
functions that aren't just Examples ( which are actually tests still ).
That way everything has a test and an example.
😂 I love how I just realized the IsPrintable()
function I wrote has basically no way for it to return false, ever. Might remove that. The Print()
function, I think, is really only useful for debugging at the moment anyway.
It can also be re-worked or added back later when actually needed.
This should solve our problems nicely, I think. https://play.golang.org/p/OwQUoohP2rn
Obviously I'm adding some stuff I feel is missing at this point.
Note: 🤷♂️ Benchmarks are weird, but sometimes helpful.
goos: darwin goarch: amd64
BenchmarkResultGetTypeThreadSafe-8 30000000 56.7 ns/op BenchmarkResultGetTypeThreadSafeMultiThreaded-8 5000000 285 ns/op BenchmarkResultGetType-8 2000000000 1.54 ns/op BenchmarkResultGetTypeMultiThreaded-8 5000000 311 ns/op BenchmarkNewResultSingleThreaded-8 20000000 87.9 ns/op BenchmarkNewResultMultiThreaded-8 5000000 309 ns/op BenchmarkInitializeEmptyResultSingleThreaded-8 2000000000 0.30 ns/op BenchmarkInitializeSuccessResultSingleThreaded-8 300000000 4.55 ns/op BenchmarkInitializeEmptyPointerToResultSingleThreaded-8 500000000 3.05 ns/op BenchmarkInitializeSuccessPointerToResultSingleThreaded-8 300000000 4.59 ns/op BenchmarkInitializeEmptyResultMulitThreaded-8 5000000 311 ns/op BenchmarkInitializeSuccessResultMulitThreaded-8 5000000 318 ns/op BenchmarkInitializeEmptyPointerToResultMulitThreaded-8 5000000 308 ns/op BenchmarkInitializeSuccessPointerToResultMulitThreaded-8 5000000 313 ns/op
Note: you can test the benchmarks like this:
$ go test -bench=.
We'll see how helpful the benchmarks are. 😂
This is a (work-in-progress) PR that aims to fix https://github.com/subfinder/research/issues/1