| 163 | } |
| 164 | |
| 165 | int ErasureCodeBench::encode() |
| 166 | { |
| 167 | ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); |
| 168 | ErasureCodeInterfaceRef erasure_code; |
| 169 | stringstream messages; |
| 170 | int code = instance.factory(plugin, |
| 171 | g_conf().get_val<std::string>("erasure_code_dir"), |
| 172 | profile, &erasure_code, &messages); |
| 173 | if (code) { |
| 174 | cerr << messages.str() << std::endl; |
| 175 | return code; |
| 176 | } |
| 177 | |
| 178 | bufferlist in; |
| 179 | in.append(string(in_size, 'X')); |
| 180 | in.rebuild_aligned(ErasureCode::SIMD_ALIGN); |
| 181 | shard_id_set want_to_encode; |
| 182 | for (shard_id_t i; i < k + m; ++i) { |
| 183 | want_to_encode.insert(i); |
| 184 | } |
| 185 | utime_t begin_time = ceph_clock_now(); |
| 186 | for (int i = 0; i < max_iterations; i++) { |
| 187 | shard_id_map<bufferlist> encoded(erasure_code->get_chunk_count()); |
| 188 | code = erasure_code->encode(want_to_encode, in, &encoded); |
| 189 | if (code) |
| 190 | return code; |
| 191 | } |
| 192 | utime_t end_time = ceph_clock_now(); |
| 193 | cout << (end_time - begin_time) << "\t" << (max_iterations * (in_size / 1024)) << std::endl; |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | static void display_chunks(const shard_id_map<bufferlist> &chunks, |
| 198 | unsigned int chunk_count) { |
no test coverage detected