Skip to content

Commit 650d8bb

Browse files
include errors are fixed
1 parent 303d8dc commit 650d8bb

File tree

4 files changed

+163
-123
lines changed

4 files changed

+163
-123
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ if(${CMAKE_BUILD_TYPE} MATCHES "Release")
3535
endif(is_supported)
3636

3737
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
38-
message(STATUS "Adding -O3 -march=native flags")
39-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native")
38+
message(STATUS "Adding -O3 -flto flags")
39+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -flto")
4040
endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
4141

4242
endif(${CMAKE_BUILD_TYPE} MATCHES "Release")
4343

44-
set(PXD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
45-
set(PXD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
44+
set(PXD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/includes)
45+
set(PXD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sources)
4646

4747
set(PXD_HEADER_FILES
4848
${PXD_INCLUDE_DIR}/lz_string.hpp

benchmark_src/benchmark.cpp

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
#include <benchmark/benchmark.h>
22

3-
#include "../src/lz_string.hpp"
3+
#include "../includes/lz_string.hpp"
44
#include "../test_src/utilities.hpp"
55

66
#define NUM_ITER 100'000
77

88
static std::string hello_world =
9-
get_text_file_content("test_src/data/hello_world/data.bin");
9+
get_text_file_content("test_src/data/hello_world/data.bin");
1010
static std::string all_ascii =
11-
get_text_file_content("test_src/data/all_ascii/data.bin");
11+
get_text_file_content("test_src/data/all_ascii/data.bin");
1212
static std::string temp_json =
13-
get_text_file_content("test_src/data/temp_json/data.bin");
13+
get_text_file_content("test_src/data/temp_json/data.bin");
1414
static std::string temp_json_float =
15-
get_text_file_content("test_src/data/temp_json_float/data.bin");
15+
get_text_file_content("test_src/data/temp_json_float/data.bin");
1616
static std::string lorem_ipsum =
17-
get_text_file_content("test_src/data/lorem_ipsum/data.bin");
18-
static std::string pi =
19-
get_text_file_content("test_src/data/pi/data.bin");
17+
get_text_file_content("test_src/data/lorem_ipsum/data.bin");
18+
static std::string pi = get_text_file_content("test_src/data/pi/data.bin");
2019
static std::string repeated =
21-
get_text_file_content("test_src/data/repeated/data.bin");
20+
get_text_file_content("test_src/data/repeated/data.bin");
2221
static std::string tattoo =
23-
get_text_file_content("test_src/data/tattoo/data.bin");
22+
get_text_file_content("test_src/data/tattoo/data.bin");
2423

2524
/*
26-
* ---------------------------------------------------------------------------------------------------
27-
* -- Compress benchmarks
28-
*/
29-
30-
#define MAKE_COMPRESS_BENCHMARK(func, inputs) \
31-
static void BM_##func##_##inputs(benchmark::State& state) { \
32-
auto input = pxd::lz_string::to_utf16(inputs); \
33-
\
34-
for(auto _ : state) { \
35-
auto compressed = pxd::lz_string::func(input); \
36-
} \
37-
} \
38-
BENCHMARK(BM_##func##_##inputs)->Iterations(NUM_ITER);
25+
* ---------------------------------------------------------------------------------------------------
26+
* -- Compress benchmarks
27+
*/
28+
29+
#define MAKE_COMPRESS_BENCHMARK(func, inputs) \
30+
static void BM_##func##_##inputs(benchmark::State& state) \
31+
{ \
32+
auto input = pxd::lz_string::to_utf16(inputs); \
33+
\
34+
for (auto _ : state) { \
35+
auto compressed = pxd::lz_string::func(input); \
36+
} \
37+
} \
38+
BENCHMARK(BM_##func##_##inputs)->Iterations(NUM_ITER);
3939

4040
MAKE_COMPRESS_BENCHMARK(compress, hello_world);
4141
MAKE_COMPRESS_BENCHMARK(compress, all_ascii);
@@ -85,16 +85,19 @@ MAKE_COMPRESS_BENCHMARK(compressUint8Array, tattoo);
8585
/*
8686
* ---------------------------------------------------------------------------------------------------
8787
* -- Decompress benchmarks
88-
*/
89-
90-
#define MAKE_DECOMPRESS_BENCHMARK(compressfunc, decompressfunc, inputs) \
91-
static void BM_decompress_##decompressfunc##_##inputs(benchmark::State& state) { \
92-
auto compressed = pxd::lz_string::compressfunc(pxd::lz_string::to_utf16(inputs)); \
93-
\
94-
for(auto _ : state) { \
95-
auto decompressed = pxd::lz_string::decompressfunc(compressed); \
96-
} \
97-
} \
88+
*/
89+
90+
#define MAKE_DECOMPRESS_BENCHMARK(compressfunc, decompressfunc, inputs) \
91+
static void BM_decompress_##decompressfunc##_##inputs( \
92+
benchmark::State& state) \
93+
{ \
94+
auto compressed = \
95+
pxd::lz_string::compressfunc(pxd::lz_string::to_utf16(inputs)); \
96+
\
97+
for (auto _ : state) { \
98+
auto decompressed = pxd::lz_string::decompressfunc(compressed); \
99+
} \
100+
} \
98101
BENCHMARK(BM_decompress_##decompressfunc##_##inputs)->Iterations(NUM_ITER);
99102

100103
MAKE_DECOMPRESS_BENCHMARK(compress, decompress, hello_world);
@@ -124,20 +127,32 @@ MAKE_DECOMPRESS_BENCHMARK(compressBase64, decompressBase64, pi);
124127
MAKE_DECOMPRESS_BENCHMARK(compressBase64, decompressBase64, repeated);
125128
MAKE_DECOMPRESS_BENCHMARK(compressBase64, decompressBase64, tattoo);
126129

127-
MAKE_DECOMPRESS_BENCHMARK(compressEncodedURI, decompressEncodedURI, hello_world);
130+
MAKE_DECOMPRESS_BENCHMARK(compressEncodedURI,
131+
decompressEncodedURI,
132+
hello_world);
128133
MAKE_DECOMPRESS_BENCHMARK(compressEncodedURI, decompressEncodedURI, all_ascii);
129134
MAKE_DECOMPRESS_BENCHMARK(compressEncodedURI, decompressEncodedURI, temp_json);
130-
MAKE_DECOMPRESS_BENCHMARK(compressEncodedURI, decompressEncodedURI, temp_json_float);
131-
MAKE_DECOMPRESS_BENCHMARK(compressEncodedURI, decompressEncodedURI, lorem_ipsum);
135+
MAKE_DECOMPRESS_BENCHMARK(compressEncodedURI,
136+
decompressEncodedURI,
137+
temp_json_float);
138+
MAKE_DECOMPRESS_BENCHMARK(compressEncodedURI,
139+
decompressEncodedURI,
140+
lorem_ipsum);
132141
MAKE_DECOMPRESS_BENCHMARK(compressEncodedURI, decompressEncodedURI, pi);
133142
MAKE_DECOMPRESS_BENCHMARK(compressEncodedURI, decompressEncodedURI, repeated);
134143
MAKE_DECOMPRESS_BENCHMARK(compressEncodedURI, decompressEncodedURI, tattoo);
135144

136-
MAKE_DECOMPRESS_BENCHMARK(compressUint8Array, decompressUint8Array, hello_world);
145+
MAKE_DECOMPRESS_BENCHMARK(compressUint8Array,
146+
decompressUint8Array,
147+
hello_world);
137148
MAKE_DECOMPRESS_BENCHMARK(compressUint8Array, decompressUint8Array, all_ascii);
138149
MAKE_DECOMPRESS_BENCHMARK(compressUint8Array, decompressUint8Array, temp_json);
139-
MAKE_DECOMPRESS_BENCHMARK(compressUint8Array, decompressUint8Array, temp_json_float);
140-
MAKE_DECOMPRESS_BENCHMARK(compressUint8Array, decompressUint8Array, lorem_ipsum);
150+
MAKE_DECOMPRESS_BENCHMARK(compressUint8Array,
151+
decompressUint8Array,
152+
temp_json_float);
153+
MAKE_DECOMPRESS_BENCHMARK(compressUint8Array,
154+
decompressUint8Array,
155+
lorem_ipsum);
141156
MAKE_DECOMPRESS_BENCHMARK(compressUint8Array, decompressUint8Array, pi);
142157
MAKE_DECOMPRESS_BENCHMARK(compressUint8Array, decompressUint8Array, repeated);
143158
MAKE_DECOMPRESS_BENCHMARK(compressUint8Array, decompressUint8Array, tattoo);

test_src/compress_uint8arr_tests.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
#include "utilities.hpp"
22

3-
#include "../src/lz_string.hpp"
3+
#include "../includes/lz_string.hpp"
44
#include <algorithm>
55
#include <gtest/gtest.h>
66

77
constexpr LZStringOptions compression = LZStringOptions::UINT8ARRAY;
88

9-
#define MAKE_COMPRESS_TEST(test_name, test_data_name) \
10-
TEST(CompressUint8Array, test_name) { \
11-
auto [input, result] = \
12-
get_compress_test_variables(test_data_name, compression); \
13-
\
14-
std::vector<uint8_t> compressed = \
15-
pxd::lz_string::compressUint8Array(pxd::lz_string::to_utf16(input)); \
16-
\
17-
std::vector<uint16_t> compressed_utf16(compressed.begin(), \
18-
compressed.end()); \
19-
\
20-
bool is_equal = \
21-
std::equal(result.begin(), result.end(), compressed_utf16.begin()); \
22-
\
23-
EXPECT_TRUE(is_equal); \
9+
#define MAKE_COMPRESS_TEST(test_name, test_data_name) \
10+
TEST(CompressUint8Array, test_name) \
11+
{ \
12+
auto [input, result] = \
13+
get_compress_test_variables(test_data_name, compression); \
14+
\
15+
std::vector<uint8_t> compressed = \
16+
pxd::lz_string::compressUint8Array(pxd::lz_string::to_utf16(input)); \
17+
\
18+
std::vector<uint16_t> compressed_utf16(compressed.begin(), \
19+
compressed.end()); \
20+
\
21+
bool is_equal = \
22+
std::equal(result.begin(), result.end(), compressed_utf16.begin()); \
23+
\
24+
EXPECT_TRUE(is_equal); \
2425
}
2526

2627
MAKE_COMPRESS_TEST(AllASCII, "all_ascii")

0 commit comments

Comments
 (0)