mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-16 17:31:51 +03:00
fix benchmarks outputs
This commit is contained in:
committed by
Konstantinos Margaritis
parent
d39e132fdf
commit
8ae4fab6c6
@@ -29,33 +29,40 @@ hwlmcb_rv_t hlmSimpleCallback(size_t to, u32 id,
|
||||
return HWLM_CONTINUE_MATCHING;
|
||||
}
|
||||
|
||||
void noodle_benchmarks(int size, int M, const char *lit_str, int lit_len, char nocase){
|
||||
void noodle_benchmarks(int size, int loops, const char *lit_str, int lit_len, char nocase){
|
||||
ctxt.clear();
|
||||
u8 *data = new u8[size];
|
||||
memset(data, 'a', size);
|
||||
long double total_sec = 0;
|
||||
long double trans_size = 0;
|
||||
long double bw = 0;
|
||||
double total_sec = 0.0;
|
||||
u64a transferred_size = 0;
|
||||
double avg_time = 0.0;
|
||||
double max_bw = 0.0;
|
||||
double bandwitdh = 0.0;
|
||||
u32 id = 1000;
|
||||
ue2::hwlmLiteral lit(std::string(lit_str, lit_len), nocase, id);
|
||||
auto n = ue2::noodBuildTable(lit);
|
||||
assert(n != nullptr);
|
||||
struct hs_scratch scratch;
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
for (int i = 0; i < M; i++){
|
||||
for (int i = 0; i < loops; i++){
|
||||
noodExec(n.get(), data, size, 0, hlmSimpleCallback, &scratch);
|
||||
}
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
total_sec += std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
|
||||
total_sec += std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
|
||||
/*calculate transferred size*/
|
||||
trans_size = size * M;
|
||||
/*convert to sec*/
|
||||
bw = trans_size / total_sec;
|
||||
transferred_size = size * loops;
|
||||
/*calculate average time*/
|
||||
avg_time = total_sec / loops;
|
||||
/*convert microseconds to seconds*/
|
||||
total_sec /= 1000000.0;
|
||||
/*calculate maximum bandwidth*/
|
||||
max_bw = transferred_size / total_sec;
|
||||
/*convert to MB/s*/
|
||||
bw /=1048576;
|
||||
/*covert average time to μs*/
|
||||
long double ms = total_sec * 1000000;
|
||||
std::cout << "\x1B[35m Case with match in random pos and size: "<< size <<" lit_len: "<< lit_len <<" nocase: "<< (int)nocase
|
||||
<< "\x1B[36m noodExec elapsetime: \x1B[0m" << (ms/M) << " (μs) \x1B[36m bandwidth: \x1B[0m" << bw <<" (MB/s)" << std::endl;
|
||||
max_bw /=1048576.0;
|
||||
/*calculate average bandwidth*/
|
||||
bandwitdh = max_bw / loops;
|
||||
printf(KMAG "Case with %u matches in random pos with %u * %u iterations," KBLU " total elapsed time =" RST " %.3f s, "
|
||||
KBLU "average time per call =" RST " %.3f μs," KBLU " bandwidth = " RST " %.3f MB/s," KBLU " average bandwidth =" RST " %.3f MB/s \n",
|
||||
lit_len, size ,loops, total_sec, avg_time, max_bw, bandwitdh);
|
||||
delete [] data;
|
||||
}
|
||||
Reference in New Issue
Block a user