Skip to content

Instantly share code, notes, and snippets.

@mdboom
Last active August 29, 2015 14:25
Show Gist options
  • Save mdboom/5769234ab3f96054adc6 to your computer and use it in GitHub Desktop.
Save mdboom/5769234ab3f96054adc6 to your computer and use it in GitHub Desktop.
from pyasdf import AsdfFile
import numpy as np
import time
for i in (10, 100, 1000, 10000):
arrays = []
for x in range(i):
arrays.append(np.random.rand(32, 32))
tree = {'arrays': arrays}
ff = AsdfFile(tree).write_to('test.asdf')
t = time.time()
with AsdfFile.open('test.asdf') as ff:
np.array(ff.tree['arrays'][i-1])
t0 = time.time() - t
ff = AsdfFile(tree).write_to('test_noindex.asdf', include_block_index=False)
t = time.time()
with AsdfFile.open('test_noindex.asdf') as ff:
np.array(ff.tree['arrays'][i-1])
t1 = time.time() - t
print("{0}: Indexed: {1}, Unindexed: {2}".format(i, t0, t1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment