Each table row shows performance measurements for this Python dev program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 1 | 2.99 | 3.00 | 8,828 | 367 | 0% 0% 100% 0% 2% 0% 0% 1% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read iobench benchmark to see what this program should do.
import os, time
def measure(func, repetitions, size):
t0 = time.time()
func(repetitions, size)
print(
func,
"%d bytes, %.2fus per write" % (
size,
(time.time() - t0) / repetitions * 1000 * 1000
)
)
def fwrite(repetitions, size):
fd = os.open("/dev/null", os.O_WRONLY)
for i in range(repetitions):
os.write(fd, b" " * size)
def fread(repetitions, size):
fd = os.open("/dev/full", os.O_RDONLY)
for i in range(repetitions):
os.read(fd, size)
def file_write(repetitions, size):
f = open("/dev/null", "w")
for i in range(repetitions):
f.write(" " * size)
f.flush()
def file_read(repetitions, size):
f = open("/dev/full")
for i in range(repetitions):
f.read(size)
if __name__ == '__main__':
measure(fread, 1000000, 100)
measure(fwrite, 1000000, 100)
measure(fread, 1000000, 1000)
measure(fwrite, 1000000, 1000)
measure(fread, 100000, 10000)
measure(fwrite, 100000, 10000)
measure(file_read, 1000000, 100)
measure(file_write, 1000000, 100)
measure(file_read, 1000000, 1000)
measure(file_write, 1000000, 1000)
measure(file_read, 100000, 10000)
measure(file_write, 100000, 10000)
Fri, 09 Sep 2022 06:02:33 GMT COMMAND LINE: /usr/bin/python3.12 iobench.python-dev 1 PROGRAM OUTPUT NOT CHECKED: <function fread at 0x7f9fc6d11260> 100 bytes, 0.30us per write <function fwrite at 0x7f9fc6d102c0> 100 bytes, 0.26us per write <function fread at 0x7f9fc6d11260> 1000 bytes, 0.39us per write <function fwrite at 0x7f9fc6d102c0> 1000 bytes, 0.33us per write <function fread at 0x7f9fc6d11260> 10000 bytes, 0.73us per write <function fwrite at 0x7f9fc6d102c0> 10000 bytes, 0.37us per write <function file_read at 0x7f9fc6d113a0> 100 bytes, 0.08us per write <function file_write at 0x7f9fc6d11300> 100 bytes, 0.07us per write <function file_read at 0x7f9fc6d113a0> 1000 bytes, 0.52us per write <function file_write at 0x7f9fc6d11300> 1000 bytes, 0.35us per write <function file_read at 0x7f9fc6d113a0> 10000 bytes, 3.66us per write <function file_write at 0x7f9fc6d11300> 10000 bytes, 2.01us per write