mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 19:24:25 +03:00
add new Literal API for pure literal expressions:
Design compile time api hs_compile_lit() and hs_compile_lit_multi() to handle pure literal pattern sets. Corresponding option --literal-on is added for hyperscan testing suites. Extended parameters and part of flags are not supported for this api.
This commit is contained in:
committed by
Chang, Harry
parent
8bfbf07f75
commit
23e5f06594
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2018, Intel Corporation
|
||||
* Copyright (c) 2016-2019, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -41,6 +41,7 @@ extern unsigned int somPrecisionMode;
|
||||
extern bool forceEditDistance;
|
||||
extern unsigned editDistance;
|
||||
extern bool printCompressSize;
|
||||
extern bool useLiteralApi;
|
||||
|
||||
/** Structure for the result of a single complete scan. */
|
||||
struct ResultEntry {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2018, Intel Corporation
|
||||
* Copyright (c) 2016-2019, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -411,22 +411,30 @@ buildEngineHyperscan(const ExpressionMap &expressions, ScanMode scan_mode,
|
||||
ext_ptr[i] = &ext[i];
|
||||
}
|
||||
|
||||
Timer timer;
|
||||
timer.start();
|
||||
|
||||
hs_compile_error_t *compile_err;
|
||||
Timer timer;
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
err = hs_compile_multi_int(patterns.data(), flags.data(), ids.data(),
|
||||
ext_ptr.data(), count, full_mode, nullptr,
|
||||
&db, &compile_err, grey);
|
||||
#else
|
||||
err = hs_compile_ext_multi(patterns.data(), flags.data(), ids.data(),
|
||||
ext_ptr.data(), count, full_mode, nullptr,
|
||||
&db, &compile_err);
|
||||
#endif
|
||||
if (useLiteralApi) {
|
||||
// Pattern length computation should be done before timer start.
|
||||
vector<size_t> lens(count);
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
lens[i] = strlen(patterns[i]);
|
||||
}
|
||||
timer.start();
|
||||
err = hs_compile_lit_multi_int(patterns.data(), flags.data(),
|
||||
ids.data(), ext_ptr.data(),
|
||||
lens.data(), count, full_mode,
|
||||
nullptr, &db, &compile_err, grey);
|
||||
timer.complete();
|
||||
} else {
|
||||
timer.start();
|
||||
err = hs_compile_multi_int(patterns.data(), flags.data(),
|
||||
ids.data(), ext_ptr.data(), count,
|
||||
full_mode, nullptr, &db, &compile_err,
|
||||
grey);
|
||||
timer.complete();
|
||||
}
|
||||
|
||||
timer.complete();
|
||||
compileSecs = timer.seconds();
|
||||
peakMemorySize = getPeakHeap();
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2018, Intel Corporation
|
||||
* Copyright (c) 2016-2019, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -87,6 +87,7 @@ unsigned int somPrecisionMode = HS_MODE_SOM_HORIZON_LARGE;
|
||||
bool forceEditDistance = false;
|
||||
unsigned editDistance = 0;
|
||||
bool printCompressSize = false;
|
||||
bool useLiteralApi = false;
|
||||
|
||||
// Globals local to this file.
|
||||
static bool compressStream = false;
|
||||
@@ -218,6 +219,7 @@ void usage(const char *error) {
|
||||
printf(" --per-scan Display per-scan Mbit/sec results.\n");
|
||||
printf(" --echo-matches Display all matches that occur during scan.\n");
|
||||
printf(" --sql-out FILE Output sqlite db.\n");
|
||||
printf(" --literal-on Use Hyperscan pure literal matching.\n");
|
||||
printf(" -S NAME Signature set name (for sqlite db).\n");
|
||||
printf("\n\n");
|
||||
|
||||
@@ -250,6 +252,7 @@ void processArgs(int argc, char *argv[], vector<BenchmarkSigs> &sigSets,
|
||||
int do_echo_matches = 0;
|
||||
int do_sql_output = 0;
|
||||
int option_index = 0;
|
||||
int literalFlag = 0;
|
||||
vector<string> sigFiles;
|
||||
|
||||
static struct option longopts[] = {
|
||||
@@ -257,6 +260,7 @@ void processArgs(int argc, char *argv[], vector<BenchmarkSigs> &sigSets,
|
||||
{"echo-matches", no_argument, &do_echo_matches, 1},
|
||||
{"compress-stream", no_argument, &do_compress, 1},
|
||||
{"sql-out", required_argument, &do_sql_output, 1},
|
||||
{"literal-on", no_argument, &literalFlag, 1},
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
@@ -463,6 +467,8 @@ void processArgs(int argc, char *argv[], vector<BenchmarkSigs> &sigSets,
|
||||
loadSignatureList(file, sigs);
|
||||
sigSets.emplace_back(file, move(sigs));
|
||||
}
|
||||
|
||||
useLiteralApi = (bool)literalFlag;
|
||||
}
|
||||
|
||||
/** Start the global timer. */
|
||||
|
Reference in New Issue
Block a user