Skip to content

Commit 99ea5e4

Browse files
committed
Add TsFile benchmark.
1 parent 19f74b0 commit 99ea5e4

33 files changed

+4523
-368
lines changed

cpp/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
2626
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=maybe-uninitialized -D__STDC_FORMAT_MACROS")
2727
endif()
2828

29-
message("cmake using: USE_CPP11=${USE_CPP11}")
3029
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
3130

3231
if(DEFINED ENV{CXX})
@@ -104,7 +103,13 @@ add_subdirectory(third_party)
104103
add_subdirectory(src)
105104
add_subdirectory(test)
106105
add_subdirectory(examples)
106+
add_subdirectory(bench_mark)
107+
set(TESTS_ENABLED ON)
107108
if(TESTS_ENABLED)
108109
add_dependencies(TsFile_Test tsfile)
109110
endif()
111+
set(BENCH_MARK_ENABLED ON)
112+
if(BENCH_MARK_ENABLED)
113+
add_dependencies(bench_mark tsfile)
114+
endif()
110115

cpp/bench_mark/CMakeLists.txt

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,37 @@ specific language governing permissions and limitations
1717
under the License.
1818
]]
1919
message("Running in bench_mark directory")
20+
cmake_minimum_required(VERSION 3.11)
21+
project(tsfile_bench_mark_project)
22+
2023
if(DEFINED ENV{CXX})
2124
set(CMAKE_CXX_COMPILER $ENV{CXX})
2225
endif()
2326

24-
set(CMAKE_CXX_FLAGS "$ENV{CXX_FLAGS} -Wall -Werror")
27+
include_directories(
28+
${LIBRARY_INCLUDE_DIR}
29+
${THIRD_PARTY_INCLUDE}
30+
${CMAKE_SOURCE_DIR}/third_party/lz4
31+
${CMAKE_SOURCE_DIR}/third_party/lzokay
32+
${CMAKE_SOURCE_DIR}/third_party/zlib-1.2.13
33+
${CMAKE_SOURCE_DIR}/third_party/google_snappy
34+
${CMAKE_SOURCE_DIR}/third_party/antlr4-cpp-runtime-4/runtime/src
35+
${CMAKE_SOURCE_DIR}/src
36+
37+
)
2538

26-
if (${USE_CPP11})
27-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
28-
set(CMAKE_CXX_STANDARD 11)
39+
link_directories(${LIBRARY_OUTPUT_PATH})
40+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
41+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
42+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
2943
else()
30-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
44+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
3145
endif()
46+
message("CMAKE DEBUG: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
3247

33-
add_subdirectory(bench_mark_src)
48+
add_executable(bench_mark
49+
src/bench_mark_cpp.cc
50+
src/bench_mark_c.cc
51+
src/bench_mark.cc
52+
src/bench_mark_utils.cc)
53+
target_link_libraries(bench_mark tsfile)

cpp/bench_mark/bench_mark_src/CMakeLists.txt

Lines changed: 0 additions & 57 deletions
This file was deleted.

cpp/bench_mark/bench_mark_src/bench_mark.cc

Lines changed: 0 additions & 161 deletions
This file was deleted.

cpp/bench_mark/build.sh

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,10 @@
1818
#
1919

2020
build_type=Debug
21-
env_for_cyber=0
2221
use_cpp11=1
2322

24-
if [[ ${env_for_cyber} -eq 1 ]]
25-
then
26-
export PATH=$PATH:~/dev/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabi/bin
27-
export CROSS_COMPILE=arm-linux-gnueabi-
28-
export ARCH=arm
29-
export CC=${CROSS_COMPILE}gcc
30-
export CXX=${CROSS_COMPILE}g++
31-
echo "set up gcc for cyber"
32-
fi
23+
mkdir -p build/Release
24+
cd build/Release
3325

34-
35-
if [ ${build_type} = "Debug" ]
36-
then
37-
mkdir -p build/Debug
38-
cd build/Debug
39-
use_sdk_debug=1
40-
else
41-
mkdir -p build/Release
42-
cd build/Release
43-
use_sdk_debug=0
44-
fi
45-
46-
echo "use_sdk_debug=${use_sdk_debug}"
47-
cmake ../../ \
48-
-DUSE_SDK_DEBUG=$use_sdk_debug \
49-
-DUSE_CPP11=$use_cpp11
26+
cmake ../../
5027
make

cpp/bench_mark/bench_mark_src/bench_conf.h renamed to cpp/bench_mark/src/bench_conf.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@
1717
* under the License.
1818
*/
1919

20+
#ifndef TSFILE_BENCH_MARK_BENCH_CONF_H
21+
#define TSFILE_BENCH_MARK_BENCH_CONF_H
22+
2023
#include <vector>
2124

2225
namespace bench {
23-
int LOOP_NUM = 100000;
24-
int THREAD_NUM = 1;
25-
int TIMESERIES_NUM = 50;
26-
std::vector<int> TYPE_LIST = {0, 0, 1, 0, 1};
26+
static int tablet_num = 1000;
27+
static int tag1_num = 1;
28+
static int tag2_num = 10;
29+
static int timestamp_per_tag = 1000;
30+
static std::vector<int> field_type_vector = {1, 1, 1, 1, 1};
2731
} // namespace bench
32+
33+
#endif // TSFILE_BENCH_MARK_BENCH_CONF_H

cpp/bench_mark/src/bench_mark.cc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* License); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include <iostream>
21+
#include <string>
22+
23+
#include "bench_mark_c_cpp.h"
24+
25+
int main(int argc, char* argv[]) {
26+
if (argc != 2) {
27+
std::cerr << "Usage: " << argv[0] << " <cpp|c>" << std::endl;
28+
return 1;
29+
}
30+
31+
std::string mode(argv[1]);
32+
33+
if (mode == "cpp") {
34+
bench_mark_cpp_write();
35+
bench_mark_cpp_read();
36+
} else if (mode == "c") {
37+
bench_mark_c_write();
38+
bench_mark_c_read();
39+
} else {
40+
std::cerr << "Invalid mode. Use 'cpp' or 'c'." << std::endl;
41+
return 1;
42+
}
43+
44+
return 0;
45+
}

0 commit comments

Comments
 (0)