issue: benchmark of reverse_integer
Closed this issue · 0 comments
WindomZ commented
Scene
Run the script:
git clone -b issues https://github.com/WindomZ/leetcode.go "$YOUR_PROJECT_PATH"
cd "$YOUR_PROJECT_PATH"
go test -test.bench=".*" ./issues/reverse_integerQuestion
1 number of CPUs:
Benchmark_A_reverse_1 100000000 15.0 ns/op
Benchmark_A_reverse_2 100000000 14.9 ns/op
Benchmark_A_reverse_3 100000000 14.2 ns/op
Benchmark_A_reverse_4 100000000 14.1 ns/op
Benchmark_B_reverse_3 100000000 14.1 ns/op
Benchmark_B_reverse_4 100000000 14.1 ns/op
Benchmark_B_reverse_1 100000000 14.9 ns/op
Benchmark_B_reverse_2 100000000 14.9 ns/op
Benchmark_C_reverse_1 100000000 14.9 ns/op
Benchmark_C_reverse_3 100000000 14.1 ns/op
Benchmark_C_reverse_2 100000000 15.0 ns/op
Benchmark_C_reverse_4 100000000 14.2 ns/op
8 number of CPUs:
Benchmark_A_reverse_1-8 100000000 14.9 ns/op
Benchmark_A_reverse_2-8 100000000 14.9 ns/op
Benchmark_A_reverse_3-8 100000000 14.2 ns/op
Benchmark_A_reverse_4-8 100000000 14.1 ns/op
Benchmark_B_reverse_3-8 100000000 14.1 ns/op
Benchmark_B_reverse_4-8 100000000 14.1 ns/op
Benchmark_B_reverse_1-8 100000000 14.9 ns/op
Benchmark_B_reverse_2-8 100000000 14.9 ns/op
Benchmark_C_reverse_1-8 100000000 14.9 ns/op
Benchmark_C_reverse_3-8 100000000 14.2 ns/op
Benchmark_C_reverse_2-8 100000000 15.0 ns/op
Benchmark_C_reverse_4-8 100000000 14.4 ns/op
Why reverse_3 and reverse_4 are faster than reverse_1 and reverse_2?