In [1]:
import numpy as np
import svbcomp, array, sys, zlib, pickle

In [14]:
SIZE_A = 1000

In [15]:
a = [0]
for i in range (SIZE_A-1):
    a.append(a[-1] + np.random.randint(0, 125))
    a = array.array('I',a)

In [16]:
res = svbcomp.dump1(a, SIZE_A)
res2 = svbcomp.load1_np_str(res, SIZE_A)
assert(np.all(res2 == a))

In [17]:
%%timeit
res2 = svbcomp.load1_np_buff(res, SIZE_A)


The slowest run took 23.64 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 1.5 µs per loop

In [18]:
%%timeit
res2 = svbcomp.load1_np_str(res, SIZE_A)


The slowest run took 9.00 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 1.23 µs per loop

In [20]:
%%timeit
res2 = np.array(svbcomp.load1(res, SIZE_A), dtype=np.uint32)


The slowest run took 83.39 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 2.25 µs per loop

In [ ]:


In [5]:
res3 = svbcomp.dump2(a, SIZE_A)
res4 = svbcomp.load2(res3, SIZE_A)
assert(res4 == res2)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-f48510530c2d> in <module>()
      1 res3 = svbcomp.dump2(a, SIZE_A)
      2 res4 = svbcomp.load2(res3, SIZE_A)
----> 3 assert(res4 == res2)

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

In [27]:
%timeit res = pickle.dumps(a)


The slowest run took 19.04 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 4.33 µs per loop

In [28]:
%timeit res = svbcomp.dump1(a, SIZE_A)


The slowest run took 8.70 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 293 ns per loop

In [29]:
%timeit res = svbcomp.dump2(a, SIZE_A)


The slowest run took 9.85 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 256 ns per loop

In [30]:
p1 = pickle.dumps(a)
r1 = svbcomp.dump1(a, SIZE_A)
r2 = svbcomp.dump2(a, SIZE_A)

In [31]:
print(sys.getsizeof(p1))
print(sys.getsizeof(r1))
print(sys.getsizeof(r2))


505
158
133

In [32]:
%timeit P = pickle.loads(p1)


The slowest run took 14.19 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 2.06 µs per loop

In [33]:
%timeit R = svbcomp.load1(r1, SIZE_A)


The slowest run took 13.45 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 557 ns per loop

In [34]:
%timeit R = svbcomp.load2(r2, SIZE_A)


The slowest run took 13.44 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 533 ns per loop

In [ ]:


In [ ]:


In [ ]:


In [ ]: