Groups
Groups
Sign in
Groups
Groups
golang-nuts
Conversations
About
Send feedback
Help
Surprising benchmark result
255 views
Skip to first unread message
tapi...@gmail.com
unread,
Jun 7, 2021, 10:57:19 AM
6/7/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
The code:
https://play.golang.org/p/DxUj6kBqf8k
The Filter4 function has one more assignment statement than Filter3.
But the benchmark result shows Filter4 is faster than Filter3.
The result:
cpu: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
BenchmarkFilter3-4 3575656 980.2 ns/op 0 B/op 0 allocs/op
BenchmarkFilter4-4 3956533 916.8 ns/op 0 B/op 0 allocs/op
jake...@gmail.com
unread,
Jun 7, 2021, 11:54:09 AM
6/7/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
FWIW I do not get the same result:
goos: windows
goarch: amd64
cpu: AMD Phenom(tm) II X4 830 Processor
BenchmarkFilter3-4 599912 1902 ns/op 0 B/op 0 allocs/op
BenchmarkFilter4-4 569143 2118 ns/op 0 B/op 0 allocs/op
PASS
peterGo
unread,
Jun 7, 2021, 1:01:49 PM
6/7/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
name time/op
Filter3-4 1.38µs ± 0%
Filter4-4 1.39µs ± 0%
On Monday, June 7, 2021 at 10:57:19 AM UTC-4
tapi...@gmail.com
wrote:
tapi...@gmail.com
unread,
Jun 7, 2021, 7:42:43 PM
6/7/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
On Monday, June 7, 2021 at 1:01:49 PM UTC-4 peterGo wrote:
name time/op
Filter3-4 1.38µs ± 0%
Filter4-4 1.39µs ± 0%
What is your CPU model?
peterGo
unread,
Jun 8, 2021, 12:19:31 AM
6/8/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
i7-7500U
name time/op
Filter3-4 1.38µs ± 0%
Filter4-4 1.39µs ± 0%
i5-8250U
name time/op
Filter3-8 1.37µs ± 0%
Filter4-8 1.39µs ± 0%
tapi...@gmail.com
unread,
Jul 7, 2021, 11:25:11 AM
7/7/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
It is found that the test file is not written correctly.
The filtered data should be reset in each loop.
The corrected one:
https://
play.golang.org/p/yJMweZLIXAz
;D
On Monday, June 7, 2021 at 10:57:19 AM UTC-4
tapi...@gmail.com
wrote:
peterGo
unread,
Jul 7, 2021, 10:04:35 PM
7/7/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Revised results using the same input data for each iteration without a copy just a Filter function.
i7-7500U
name time/op
Filter3-4 2.29µs ± 0%
Filter4-4 1.51µs ± 0%
i5-8250U
name time/op
Filter3-8 2.30µs ± 0%
Filter4-8 1.53µs ± 0%
Peter
Reply all
Reply to author
Forward
0 new messages