kamalmarhubi / one-second

Fun performance game!
http://computers-are-fast.github.io/
389 stars 22 forks source link

Avoid laziness of StringIO.write spoiling benchmark correctness. #20

Open thundergolfer opened 2 years ago

thundergolfer commented 2 years ago

Without output.getvalue() the StringIO object will just accumulate references to s until it hits 100,000 references, at which point the internal buffer will actually be realized.

Currently, this benchmark can be run and do 99,999 .write() operations on the StringIO object but 99_999 * CHUNK_SIZE bytes are not written into memory as a single 99GB buffer.