Пример #1
0
usage = """usage: %s recordlength
     Set recordlength to 1000 at least to obtain decent figures!
""" % sys.argv[0]

try:
    reclen = int(sys.argv[1])
except:
    print(usage)
    sys.exit()

delta = 0.000_001

# Creation of recarrays objects for test
x1 = np.array(np.arange(reclen))
x2 = chararray.array(None, itemsize=7, shape=reclen)
x3 = np.array(np.arange(reclen, reclen * 3, 2), np.Float64)
r1 = recarray.fromarrays([x1, x2, x3], names='a,b,c')
r2 = recarray2.fromarrays([x1, x2, x3], names='a,b,c')

print("recarray shape in test ==>", r2.shape)

print("Assignment in recarray original")
print("-------------------------------")
t1 = clock()
for row in range(reclen):
    #r1.field("b")[row] = "changed"
    r1.field("c")[row] = float(row**2)
t2 = clock()
origtime = t2 - t1
print(f"Assign time: {origtime:.3f} Rows/s: {reclen / (origtime + delta):.0f}")
Пример #2
0
usage = \
"""usage: %s recordlength
     Set recordlength to 1000 at least to obtain decent figures!
""" % sys.argv[0]

try:
    reclen = int(sys.argv[1])
except:
    print usage
    sys.exit()

delta = 0.000001

# Creation of recarrays objects for test
x1=num.array(num.arange(reclen))
x2=chararray.array(None, itemsize=7, shape=reclen)
x3=num.array(num.arange(reclen, reclen*3, 2), num.Float64)
r1=recarray.fromarrays([x1, x2, x3], names='a,b,c')
r2=recarray2.fromarrays([x1, x2, x3], names='a,b,c')

print "recarray shape in test ==>", r2.shape

print "Assignment in recarray original"
print "-------------------------------"
t1 = time.clock()
for row in xrange(reclen):
    #r1.field("b")[row] = "changed"
    r1.field("c")[row] = float(row**2)
t2 = time.clock()
origtime = round(t2-t1, 3)
print "Assign time:", origtime, " Rows/s:", int(reclen/(origtime+delta))