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 -- 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.
concat_test.go
Description: Binary data
def mysetup(): #pass global s global t s = u''.join(map(str, range(100))) t = u''.join(map(str, range(1, 101))) #@profile def concat(): #1 _ = t + s _ = t + s _ = t + s _ = t + s _ = t + s #2 _ = t + s _ = t + s _ = t + s _ = t + s _ = t + s #3 _ = t + s _ = t + s _ = t + s _ = t + s _ = t + s #4 _ = t + s _ = t + s _ = t + s _ = t + s _ = t + s #5 _ = t + s _ = t + s _ = t + s _ = t + s _ = t + s #6 _ = t + s _ = t + s _ = t + s _ = t + s _ = t + s #7 _ = t + s _ = t + s _ = t + s _ = t + s _ = t + s #8 _ = t + s _ = t + s _ = t + s _ = t + s _ = t + s #9 _ = t + s _ = t + s _ = t + s _ = t + s _ = t + s #10 _ = t + s _ = t + s _ = t + s _ = t + s _ = t + s if __name__ == "__main__": s = None t = None loops = 1000000 import timeit times = timeit.Timer(stmt="from __main__ import concat",setup="gc.enable();from __main__ import mysetup").repeat(7,loops) time_taken = min(times)/loops print ("time_taken = %s nsec\n" %(time_taken*1000000000))