import time
def concat():
start = time.time()
s = ""
s += "Вася"
s += "1"
return time.time() - start
def join():
start = time.time()
lst = ["Вася", "1"]
s = "".join(lst)
return time.time() - start
reps = 1000000
ct = 0
jt = 0
for i in range(reps):
ct += concat()
jt += join()
print("%d join = %.6f" % (reps, jt))
print("%d concat = %.6f" % (reps, ct))
aW1wb3J0IHRpbWUKCmRlZiBjb25jYXQoKToKCXN0YXJ0ID0gdGltZS50aW1lKCkKCXMgPSAiIgoJcyArPSAi0JLQsNGB0Y8iCglzICs9ICIxIgoJcmV0dXJuIHRpbWUudGltZSgpIC0gc3RhcnQKCgpkZWYgam9pbigpOgoJc3RhcnQgPSB0aW1lLnRpbWUoKQoJbHN0ID0gWyLQktCw0YHRjyIsICIxIl0KCXMgPSAiIi5qb2luKGxzdCkKCXJldHVybiB0aW1lLnRpbWUoKSAtIHN0YXJ0CgpyZXBzID0gMTAwMDAwMApjdCA9IDAKanQgPSAwCmZvciBpIGluIHJhbmdlKHJlcHMpOgoJY3QgKz0gY29uY2F0KCkKCWp0ICs9IGpvaW4oKQoKcHJpbnQoIiVkIGpvaW4gPSAlLjZmIiAlIChyZXBzLCBqdCkpCnByaW50KCIlZCBjb25jYXQgPSAlLjZmIiAlIChyZXBzLCBjdCkp