colorfulappl <colorfula...@qq.com> added the comment:

I wrote some microbenchs.

Patch: 
https://github.com/python/cpython/pull/30312/commits/b68176d081e19a3cedbaf2cdb31ecd7690421ec8

Environment:
macOS 12.1
clang 13.0.0
configure with --enable-optimizations

Result on microbench:

```
+--------------------------------------------+-------------------------+------------------------+
| Benchmark                                  | ./opt_baseline/res.json | 
./opt_patched/res.json |
+============================================+=========================+========================+
| print(a, b, c)                             | 917 ns                  | 820 
ns: 1.12x faster   |
+--------------------------------------------+-------------------------+------------------------+
| print(a, b, c, *v)                         | 1.56 us                 | 1.62 
us: 1.04x slower  |
+--------------------------------------------+-------------------------+------------------------+
| print(a, sep='', file=stdout)              | 376 ns                  | 295 
ns: 1.27x faster   |
+--------------------------------------------+-------------------------+------------------------+
| print(*v, sep='', flush=True, file=stdout) | 2.02 us                 | 1.94 
us: 1.04x faster  |
+--------------------------------------------+-------------------------+------------------------+
| Geometric mean                             | (ref)                   | 1.05x 
faster           |
+--------------------------------------------+-------------------------+------------------------+

Benchmark hidden because not significant (3): print(a), print(a, sep='', 
flush=True, file=stdout), print(a, b, c, *v, sep='', flush=True, file=stdout)
```

----------
Added file: https://bugs.python.org/file50533/bench-print.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46212>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to