def bench_length():
repeat = 1
nb_points_per_streamline = 100
nb_streamlines = int(1e5)
streamlines = [np.random.rand(nb_points_per_streamline,
3).astype("float32")
for i in range(nb_streamlines)]
print("Timing length() in Cython ({0} streamlines)".format(nb_streamlines))
cython_time = measure("length(streamlines)", repeat)
After Change
print("Speed up of {0:.2f}x".format(python_time/cython_time))
streamlines = DATA["streamlines_arrseq"]
cython_time_arrseq = measure("length(streamlines)", repeat)
print("Cython time (ArraySequence): {0:.3}sec".format(cython_time_arrseq))
print("Speed up of {0:.2f}x".format(python_time/cython_time_arrseq))
// Make sure all methods produce the same results.