Skip to content

Commit

Permalink
[fix][tests] Using constant reference to dataset to avoid copying (#1…
Browse files Browse the repository at this point in the history
…110)
  • Loading branch information
abdelrahim-hentabli authored Dec 7, 2024
1 parent 32d65c2 commit ddf1540
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tools/benchmarks/src/cases/crc64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ BENCHMARK_SET_DELAYED(crc64) {
const std::vector<crc_type_e> crc_types {crc_type_e::crc32_gzip, crc_type_e::crc32_wimax, crc_type_e::crc32_iscsi,
crc_type_e::T10DIF, crc_type_e::crc16_ccitt, crc_type_e::crc64};

auto dataset = data::read_dataset(cmd::FLAGS_dataset);
const auto& dataset = data::read_dataset(cmd::FLAGS_dataset);
for (auto& data : dataset) {
block_sizes = (cmd::get_block_size() >= 0)
? std::vector<uint32_t> {static_cast<uint32_t>(cmd::get_block_size())}
Expand Down
2 changes: 1 addition & 1 deletion tools/tests/cross_tests/canned_one_chuck_hw_vs_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class SimpleCannedOneChuckCompressDecompressFixture
void SetUpBeforeIteration() override {
current_test_case = GetTestCase();

auto dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();
const auto& dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();

reference_text = dataset[current_test_case.file_name];

Expand Down
2 changes: 1 addition & 1 deletion tools/tests/cross_tests/compression_hw_vs_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class SimpleCompressDecompressFixture
void SetUpBeforeIteration() override {
current_test_case = GetTestCase();

auto dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();
const auto& dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();

reference_text = dataset[current_test_case.file_name];

Expand Down
2 changes: 1 addition & 1 deletion tools/tests/cross_tests/huffman_only_hw_vs_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class SimpleHuffmanOnlyCompressDecompressFixture
void SetUpBeforeIteration() override {
current_test_case = GetTestCase();

auto dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();
const auto& dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();

reference_text = dataset[current_test_case.file_name];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DeflateTest : public JobFixtureWithTestCases<DeflateTestCase> {

protected:
void InitializeTestCases() override {
auto dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();
const auto& dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();
for (auto& data : dataset.get_data()) {
DeflateTestCase test_case {};
test_case.file_name = data.first;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class IndexTest : public JobFixtureWithTestCases<IndexTestCase> {
void SetUpBeforeIteration() override {
current_test_case = GetTestCase();

auto dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();
const auto& dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();

std::vector<uint8_t> source_ptr = dataset[current_test_case.file_name];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Inflate : public JobFixture {
job_ptr->op = qpl_op_decompress;
job_ptr->flags = QPL_FLAG_FIRST | QPL_FLAG_LAST;

auto dataset = util::TestEnvironment::GetInstance().GetCompleteDataset();
const auto& dataset = util::TestEnvironment::GetInstance().GetCompleteDataset();

try {
reference_data = dataset[decompressed_file_name];
Expand Down Expand Up @@ -108,7 +108,7 @@ class Inflate : public JobFixture {

private:
void SetSourceFromFile(std::string& file_name) {
auto dataset = util::TestEnvironment::GetInstance().GetCompleteDataset();
const auto& dataset = util::TestEnvironment::GetInstance().GetCompleteDataset();

source = dataset[file_name]; // store to original data to reference vector

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class InflatePipelineTest : public JobFixtureWithTestCases<std::string> {
deflate_job_ptr = reinterpret_cast<qpl_job*>(job_buffer.get());
}

auto dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();
const auto& dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();

source = dataset[GetTestCase()];
// Huge size due to potentially tiny block compression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class inflate_stop_condtition_test : public JobFixture {

// 1.a Identical test to 1, except for the fact, that there's only one bfinal eob symbol
QPL_LOW_LEVEL_API_ALGORITHMIC_TEST_F(inflate_stop_conditions, dont_stop_on_eob, inflate_stop_condtition_test) {
auto dataset = util::TestEnvironment::GetInstance().GetCompleteDataset();
source = dataset["file1"];
const auto& dataset = util::TestEnvironment::GetInstance().GetCompleteDataset();
source = dataset["file1"];

std::vector<uint8_t> compressed_source(source.size() * 2);
destination.resize(compressed_source.size() * 2);
Expand Down Expand Up @@ -99,8 +99,8 @@ QPL_LOW_LEVEL_API_ALGORITHMIC_TEST_F(inflate_stop_conditions, dont_stop_on_eob,

// 2. Stop on any EOB symbol
QPL_LOW_LEVEL_API_ALGORITHMIC_TEST_F(inflate_stop_conditions, stop_on_eob, inflate_stop_condtition_test) {
auto dataset = util::TestEnvironment::GetInstance().GetCompleteDataset();
source = dataset["file1"];
const auto& dataset = util::TestEnvironment::GetInstance().GetCompleteDataset();
source = dataset["file1"];

std::vector<uint8_t> compressed_source(source.size() * 2);
destination.resize(compressed_source.size() * 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class JobReusageTest : public JobFixtureWithTestCases<std::string> {
void SetUpBeforeIteration() override {
auto current_test_case = GetTestCase();

auto dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();
const auto& dataset = util::TestEnvironment::GetInstance().GetAlgorithmicDataset();

source = dataset[current_test_case];
}
Expand Down

0 comments on commit ddf1540

Please sign in to comment.