On 02/27/2017 07:21 PM, Ian Lance Taylor wrote: > On Mon, Feb 27, 2017 at 3:58 PM, Shubha Ramani > <shubharam...@gmail.com> wrote: >> Please see the attached two scripts. >> >> Use python3 for concat_test.py. >> >> I'm getting 591 nsec for the micro benchmark in python and 4453 ns >> for the microbenchmark in go. I stole this benchmark from >> Unicode.py of pybench, but changed it a bit. >> >> (py36env) shubha@shubha-Z170X-UD5:~/myperformance$ go test >> --bench=UnicodeConcat BenchmarkUnicodeConcat-8 300000 4453 >> ns/op >> >> (py36env) shubha@shubha-Z170X-UD5:~/myperformance$ python >> concat_test.py time_taken = 591.0059640882537 nsec > > I'm no Python expert, but I don't see any evidence that your Python > code is actually executing either mysetup or concat. >
I noticed the same thing. Even after you do call myinit() the performance difference is still the same with python2.7. python3 has similar performance to Go: ayan@kiwi:~/unicode$ python --version Python 2.7.13 ayan@kiwi:~/unicode$ python ./concat_test.py time_taken = 924.661159515 nsec ayan@kiwi:~/unicode$ python3 ./concat_test.py time_taken = 2005.0194200011902 nsec ayan@kiwi:~/unicode$ go test -bench=. BenchmarkUnicodeConcat-2 100000 19751 ns/op PASS ok _/home/ayan/unicode 2.175s Here's pprof output on my machine. The runtime.memclr() call sticks out to me. ayan@kiwi:~/unicode$ go tool pprof prof.cpu Entering interactive mode (type "help" for commands) (pprof) top10 1090ms of 1430ms total (76.22%) Showing top 10 nodes out of 103 (cum >= 20ms) flat flat% sum% cum cum% 480ms 33.57% 33.57% 480ms 33.57% runtime.memmove 240ms 16.78% 50.35% 240ms 16.78% runtime.memclr 110ms 7.69% 58.04% 550ms 38.46% runtime.mallocgc 60ms 4.20% 62.24% 1180ms 82.52% runtime.concatstrings 40ms 2.80% 65.03% 40ms 2.80% runtime.futex 40ms 2.80% 67.83% 40ms 2.80% runtime.heapBitsForObject 40ms 2.80% 70.63% 40ms 2.80% runtime/internal/atomic.Xchg 30ms 2.10% 72.73% 80ms 5.59% runtime.(*mheap).allocSpanLocked 30ms 2.10% 74.83% 620ms 43.36% runtime.rawstring 20ms 1.40% 76.22% 20ms 1.40% runtime.(*mSpanList).remove (pprof) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.