|
39 | 39 | toc = time.time() |
40 | 40 | tcpy = (toc - tic) / NREP |
41 | 41 | print( |
42 | | - " Time for copying array with np.copy: %.3f s (%.2f GB/s))" |
43 | | - % (tcpy, ((N * 8 / tcpy) / 2**30)) |
| 42 | + " Time for copying array with np.copy: {:.3f} s ({:.2f} GB/s))" |
| 43 | + .format(tcpy, ((N * 8 / tcpy) / 2**30)) |
44 | 44 | ) |
45 | 45 |
|
46 | 46 | if comprehensive_copy_timing: |
|
51 | 51 | toc = time.time() |
52 | 52 | tcpy = (toc - tic) / NREP |
53 | 53 | print( |
54 | | - " Time for copying array with np.copyto and empty_like: %.3f s (%.2f GB/s))" |
55 | | - % (tcpy, ((N * 8 / tcpy) / 2**30)) |
| 54 | + " Time for copying array with np.copyto and empty_like: {:.3f} s ({:.2f} GB/s))" |
| 55 | + .format(tcpy, ((N * 8 / tcpy) / 2**30)) |
56 | 56 | ) |
57 | 57 |
|
58 | 58 | # Unlike numpy.zeros, numpy.zeros_like doesn't use calloc, but instead uses |
|
66 | 66 | toc = time.time() |
67 | 67 | tcpy = (toc - tic) / NREP |
68 | 68 | print( |
69 | | - " Time for copying array with np.copyto and zeros: %.3f s (%.2f GB/s))" |
70 | | - % (tcpy, ((N * 8 / tcpy) / 2**30)) |
| 69 | + " Time for copying array with np.copyto and zeros: {:.3f} s ({:.2f} GB/s))" |
| 70 | + .format(tcpy, ((N * 8 / tcpy) / 2**30)) |
71 | 71 | ) |
72 | 72 |
|
73 | 73 | # Cause a page fault before the benchmark |
|
78 | 78 | toc = time.time() |
79 | 79 | tcpy = (toc - tic) / NREP |
80 | 80 | print( |
81 | | - " Time for copying array with np.copyto and full_like: %.3f s (%.2f GB/s))" |
82 | | - % (tcpy, ((N * 8 / tcpy) / 2**30)) |
| 81 | + " Time for copying array with np.copyto and full_like: {:.3f} s ({:.2f} GB/s))" |
| 82 | + .format(tcpy, ((N * 8 / tcpy) / 2**30)) |
83 | 83 | ) |
84 | 84 |
|
85 | 85 | tic = time.time() |
|
89 | 89 | toc = time.time() |
90 | 90 | tcpy = (toc - tic) / NREP |
91 | 91 | print( |
92 | | - " Time for copying array with numpy assignment: %.3f s (%.2f GB/s))" |
93 | | - % (tcpy, ((N * 8 / tcpy) / 2**30)) |
| 92 | + " Time for copying array with numpy assignment: {:.3f} s ({:.2f} GB/s))" |
| 93 | + .format(tcpy, ((N * 8 / tcpy) / 2**30)) |
94 | 94 | ) |
95 | 95 |
|
96 | 96 | print() |
97 | 97 | filters = [blosc2.Filter.SHUFFLE, blosc2.Filter.BYTEDELTA] |
98 | 98 | print(f"Using {filters=}") |
99 | 99 |
|
100 | 100 | for in_, label in arrays: |
101 | | - print("\n*** %s ***" % label) |
| 101 | + print(f"\n*** {label} ***") |
102 | 102 | for codec in blosc2.compressor_list(): |
103 | 103 | clevel = 6 |
104 | 104 | print(f"Using *** {codec} (clevel {clevel}) *** :") |
|
122 | 122 | tc = (ctoc - ctic) / NREP |
123 | 123 | td = (dtoc - dtic) / NREP |
124 | 124 | print( |
125 | | - " Time for compress/decompress: %.3f/%.3f s (%.2f/%.2f GB/s)) " |
126 | | - % (tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)), |
| 125 | + " Time for compress/decompress: {:.3f}/{:.3f} s ({:.2f}/{:.2f} GB/s)) " |
| 126 | + .format(tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)), |
127 | 127 | end="", |
128 | 128 | ) |
129 | | - print("\tcr: %5.1fx" % (in_.size * in_.dtype.itemsize * 1.0 / len(c))) |
| 129 | + print("\tcr: {:5.1f}x".format(in_.size * in_.dtype.itemsize * 1.0 / len(c))) |
130 | 130 |
|
131 | 131 | ctic = time.time() |
132 | 132 | for i in range(NREP): |
|
141 | 141 | tc = (ctoc - ctic) / NREP |
142 | 142 | td = (dtoc - dtic) / NREP |
143 | 143 | print( |
144 | | - " Time for pack_array2/unpack_array2: %.3f/%.3f s (%.2f/%.2f GB/s)) " |
145 | | - % (tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)), |
| 144 | + " Time for pack_array2/unpack_array2: {:.3f}/{:.3f} s ({:.2f}/{:.2f} GB/s)) " |
| 145 | + .format(tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)), |
146 | 146 | end="", |
147 | 147 | ) |
148 | | - print("\tcr: %5.1fx" % (in_.size * in_.dtype.itemsize * 1.0 / len(c))) |
| 148 | + print("\tcr: {:5.1f}x".format(in_.size * in_.dtype.itemsize * 1.0 / len(c))) |
149 | 149 |
|
150 | 150 | ctic = time.time() |
151 | 151 | for i in range(NREP): |
|
160 | 160 | tc = (ctoc - ctic) / NREP |
161 | 161 | td = (dtoc - dtic) / NREP |
162 | 162 | print( |
163 | | - " Time for pack_tensor/unpack_tensor: %.3f/%.3f s (%.2f/%.2f GB/s)) " |
164 | | - % (tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)), |
| 163 | + " Time for pack_tensor/unpack_tensor: {:.3f}/{:.3f} s ({:.2f}/{:.2f} GB/s)) " |
| 164 | + .format(tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)), |
165 | 165 | end="", |
166 | 166 | ) |
167 | | - print("\tcr: %5.1fx" % (in_.size * in_.dtype.itemsize * 1.0 / len(c))) |
| 167 | + print("\tcr: {:5.1f}x".format(in_.size * in_.dtype.itemsize * 1.0 / len(c))) |
0 commit comments