Permalink
Browse files
Use bytearray instead of array.array
I'm just gonna leave this here:
>>> timeit.timeit("array.array(u'B', itertools.repeat(0, 4096))",
number=10000,
setup="import array; import itertools")
3.422340818680823
>>> timeit.timeit("a=bytearray(4096)", number=10000)
0.0034010084345936775
Yes, you're seeing it right. 1000x faster. Especially for the block
group searches, which we are doing a lot of separately each time, this
makes a huge difference.
For a real life benchmark... On a large filesystem with >40k blockgroups
I have this reduces the time to retrieve and list all the items about
them (all info in disk cache) from 18 to 3 seconds.- Loading branch information
Showing
with
11 additions
and 18 deletions.
- +1 −3 btrfs/crc32c.py
- +10 −15 btrfs/ioctl.py