mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
hsbench: add CSV dump support
This commit is contained in:
parent
87413fbff0
commit
7d21fc157c
@ -88,6 +88,8 @@ public:
|
|||||||
|
|
||||||
virtual void printStats() const = 0;
|
virtual void printStats() const = 0;
|
||||||
|
|
||||||
|
virtual void printCsvStats() const = 0;
|
||||||
|
|
||||||
virtual void sqlStats(SqlDB &db) const = 0;
|
virtual void sqlStats(SqlDB &db) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -187,6 +187,16 @@ void EngineChimera::printStats() const {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EngineChimera::printCsvStats() const {
|
||||||
|
printf(",\"%s\"", compile_stats.signatures.c_str());
|
||||||
|
printf(",\"%zu\"", compile_stats.expressionCount);
|
||||||
|
printf(",\"0x%x\"", compile_stats.crc32);
|
||||||
|
printf(",\"%zu\"", compile_stats.compiledSize);
|
||||||
|
printf(",\"%zu\"", compile_stats.scratchSize);
|
||||||
|
printf(",\"%0.3Lf\"", compile_stats.compileSecs);
|
||||||
|
printf(",\"%u\"", compile_stats.peakMemorySize);
|
||||||
|
}
|
||||||
|
|
||||||
void EngineChimera::sqlStats(SqlDB &sqldb) const {
|
void EngineChimera::sqlStats(SqlDB &sqldb) const {
|
||||||
ostringstream crc;
|
ostringstream crc;
|
||||||
crc << "0x" << hex << compile_stats.crc32;
|
crc << "0x" << hex << compile_stats.crc32;
|
||||||
|
@ -89,6 +89,8 @@ public:
|
|||||||
|
|
||||||
void printStats() const;
|
void printStats() const;
|
||||||
|
|
||||||
|
void printCsvStats() const;
|
||||||
|
|
||||||
void sqlStats(SqlDB &db) const;
|
void sqlStats(SqlDB &db) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -276,6 +276,17 @@ void EngineHyperscan::printStats() const {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EngineHyperscan::printCsvStats() const {
|
||||||
|
printf(",\"%s\"", compile_stats.signatures.c_str());
|
||||||
|
printf(",\"%zu\"", compile_stats.expressionCount);
|
||||||
|
printf(",\"0x%x\"", compile_stats.crc32);
|
||||||
|
printf(",\"%zu\"", compile_stats.compiledSize);
|
||||||
|
printf(",\"%zu\"", compile_stats.streamSize);
|
||||||
|
printf(",\"%zu\"", compile_stats.scratchSize);
|
||||||
|
printf(",\"%0.3Lf\"", compile_stats.compileSecs);
|
||||||
|
printf(",\"%u\"", compile_stats.peakMemorySize);
|
||||||
|
}
|
||||||
|
|
||||||
void EngineHyperscan::sqlStats(SqlDB &sqldb) const {
|
void EngineHyperscan::sqlStats(SqlDB &sqldb) const {
|
||||||
ostringstream crc;
|
ostringstream crc;
|
||||||
crc << "0x" << hex << compile_stats.crc32;
|
crc << "0x" << hex << compile_stats.crc32;
|
||||||
|
@ -98,6 +98,8 @@ public:
|
|||||||
|
|
||||||
void printStats() const;
|
void printStats() const;
|
||||||
|
|
||||||
|
void printCsvStats() const;
|
||||||
|
|
||||||
void sqlStats(SqlDB &db) const;
|
void sqlStats(SqlDB &db) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -227,6 +227,15 @@ void EnginePCRE::printStats() const {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EnginePCRE::printCsvStats() const {
|
||||||
|
printf(",\"%s\"", compile_stats.signatures.c_str());
|
||||||
|
printf(",\"%zu\"", compile_stats.expressionCount);
|
||||||
|
printf(",\"%zu\"", compile_stats.compiledSize);
|
||||||
|
printf(",\"%zu\"", compile_stats.scratchSize);
|
||||||
|
printf(",\"%0.3Lf\"", compile_stats.compileSecs);
|
||||||
|
printf(",\"%u\"", compile_stats.peakMemorySize);
|
||||||
|
}
|
||||||
|
|
||||||
void EnginePCRE::sqlStats(SqlDB &sqldb) const {
|
void EnginePCRE::sqlStats(SqlDB &sqldb) const {
|
||||||
ostringstream crc;
|
ostringstream crc;
|
||||||
|
|
||||||
|
@ -97,6 +97,8 @@ public:
|
|||||||
|
|
||||||
void printStats() const;
|
void printStats() const;
|
||||||
|
|
||||||
|
void printCsvStats() const;
|
||||||
|
|
||||||
void sqlStats(SqlDB &db) const;
|
void sqlStats(SqlDB &db) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -98,6 +98,7 @@ bool display_per_scan = false;
|
|||||||
ScanMode scan_mode = ScanMode::STREAMING;
|
ScanMode scan_mode = ScanMode::STREAMING;
|
||||||
bool useHybrid = false;
|
bool useHybrid = false;
|
||||||
bool usePcre = false;
|
bool usePcre = false;
|
||||||
|
bool dumpCsvOut = false;
|
||||||
unsigned repeats = 20;
|
unsigned repeats = 20;
|
||||||
string exprPath("");
|
string exprPath("");
|
||||||
string corpusFile("");
|
string corpusFile("");
|
||||||
@ -211,6 +212,7 @@ void usage(const char *error) {
|
|||||||
printf(" Benchmark with threads on specified CPUs or CPU"
|
printf(" Benchmark with threads on specified CPUs or CPU"
|
||||||
" range.\n");
|
" range.\n");
|
||||||
#endif
|
#endif
|
||||||
|
printf(" -C Dump CSV output for tput matrix.\n");
|
||||||
printf(" -i DIR Don't compile, load from files in DIR"
|
printf(" -i DIR Don't compile, load from files in DIR"
|
||||||
" instead.\n");
|
" instead.\n");
|
||||||
printf(" -w DIR After compiling, save to files in DIR.\n");
|
printf(" -w DIR After compiling, save to files in DIR.\n");
|
||||||
@ -275,6 +277,9 @@ void processArgs(int argc, char *argv[], vector<BenchmarkSigs> &sigSets,
|
|||||||
case 'c':
|
case 'c':
|
||||||
corpusFile.assign(optarg);
|
corpusFile.assign(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'C':
|
||||||
|
dumpCsvOut = true;
|
||||||
|
break;
|
||||||
case 'd': {
|
case 'd': {
|
||||||
unsigned dist;
|
unsigned dist;
|
||||||
if (!fromString(optarg, dist)) {
|
if (!fromString(optarg, dist)) {
|
||||||
@ -849,6 +854,39 @@ void displayResults(const vector<unique_ptr<ThreadContext>> &threads,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Dump benchmark results to csv. */
|
||||||
|
static
|
||||||
|
void displayCsvResults(const vector<unique_ptr<ThreadContext>> &threads,
|
||||||
|
const vector<DataBlock> &corpus_blocks) {
|
||||||
|
u64a bytesPerRun = byte_size(corpus_blocks);
|
||||||
|
u64a matchesPerRun = threads[0]->results[0].matches;
|
||||||
|
|
||||||
|
// Sanity check: all of our results should have the same match count.
|
||||||
|
for (const auto &t : threads) {
|
||||||
|
if (!all_of(begin(t->results), end(t->results),
|
||||||
|
[&matchesPerRun](const ResultEntry &e) {
|
||||||
|
return e.matches == matchesPerRun;
|
||||||
|
})) {
|
||||||
|
printf("\nWARNING: PER-SCAN MATCH COUNTS ARE INCONSISTENT!\n\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u64a totalBytes = bytesPerRun * repeats * threads.size();
|
||||||
|
u64a totalBlocks = corpus_blocks.size() * repeats * threads.size();
|
||||||
|
printf(",\"%0.3f\"", totalSecs);
|
||||||
|
printf(",\"%0.2Lf\"", calc_mbps(totalSecs, totalBytes));
|
||||||
|
|
||||||
|
double matchRate = ((double)matchesPerRun * 1024) / bytesPerRun;
|
||||||
|
printf(",\"%llu\"", matchesPerRun);
|
||||||
|
printf(",\"%0.3f\"", matchRate);
|
||||||
|
|
||||||
|
double blockRate = (double)totalBlocks / (double)totalSecs;
|
||||||
|
printf(",\"%0.2f\"", blockRate);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Dump per-scan throughput data to sql. */
|
/** Dump per-scan throughput data to sql. */
|
||||||
static
|
static
|
||||||
void sqlPerScanResults(const vector<unique_ptr<ThreadContext>> &threads,
|
void sqlPerScanResults(const vector<unique_ptr<ThreadContext>> &threads,
|
||||||
@ -982,7 +1020,9 @@ void runBenchmark(const Engine &db,
|
|||||||
t->join();
|
t->join();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sqloutFile.empty()) {
|
if (dumpCsvOut) {
|
||||||
|
displayCsvResults(threads, corpus_blocks);
|
||||||
|
} else if (sqloutFile.empty()) {
|
||||||
// Display global results.
|
// Display global results.
|
||||||
displayResults(threads, corpus_blocks);
|
displayResults(threads, corpus_blocks);
|
||||||
} else {
|
} else {
|
||||||
@ -1059,7 +1099,9 @@ int HS_CDECL main(int argc, char *argv[]) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sqloutFile.empty()) {
|
if (dumpCsvOut) {
|
||||||
|
engine->printCsvStats();
|
||||||
|
} else if (sqloutFile.empty()) {
|
||||||
// Display global results.
|
// Display global results.
|
||||||
engine->printStats();
|
engine->printStats();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user