3 ms·
I can imagine the overhead for ints is large. But how often do you sort pure ints? A more realistic test would be some objects sorted on a field value.
by praptak 10y ago
I can imagine the overhead for ints is large. But how often do you sort pure ints? A more realistic test would be some objects sorted on a field value.
- nieksand 10y agoThat's great feedback. I'll try out this specialization on a simple struct (int32/string) combo later today. We can still get rid of the indirections around slice manipulation (Swap and Len) but obviously stay stuck with the Less.
- pettou 10y agoOr try sorting points (struct of two float64s) by the x-coordinate, and compare the timing with similar JavaScript code running in V8. You might be surprised...
- nieksand 10y agoI've updated the repo and README.md to reflect this case. For sorting a struct with (int,string) on it's random integer value, I got the following: [10K elements] BenchmarkLibPotato-4 10000 2166569 ns/op BenchmarkSpecPotato-4 10000 1020842 ns/op [10M elements] BenchmarkLibPotato-4 3 3829722562 ns/op BenchmarkSpecPotato-4 10 1802874882 ns/op