Skip to content

Bench mark for multi languages. #459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=maybe-uninitialized -D__STDC_FORMAT_MACROS")
endif()

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

if(DEFINED ENV{CXX})
Expand Down Expand Up @@ -104,7 +103,13 @@ add_subdirectory(third_party)
add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(examples)
add_subdirectory(bench_mark)
set(TESTS_ENABLED ON)
if(TESTS_ENABLED)
add_dependencies(TsFile_Test tsfile)
endif()
set(BENCH_MARK_ENABLED ON)
if(BENCH_MARK_ENABLED)
add_dependencies(bench_mark tsfile)
endif()

37 changes: 31 additions & 6 deletions cpp/bench_mark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,42 @@ specific language governing permissions and limitations
under the License.
]]
message("Running in bench_mark directory")
cmake_minimum_required(VERSION 3.11)
project(tsfile_bench_mark_project)

if(DEFINED ENV{CXX})
set(CMAKE_CXX_COMPILER $ENV{CXX})
endif()

set(CMAKE_CXX_FLAGS "$ENV{CXX_FLAGS} -Wall -Werror")
include_directories(
${LIBRARY_INCLUDE_DIR}
${THIRD_PARTY_INCLUDE}
${CMAKE_SOURCE_DIR}/third_party/lz4
${CMAKE_SOURCE_DIR}/third_party/lzokay
${CMAKE_SOURCE_DIR}/third_party/zlib-1.2.13
${CMAKE_SOURCE_DIR}/third_party/google_snappy
${CMAKE_SOURCE_DIR}/third_party/antlr4-cpp-runtime-4/runtime/src
${CMAKE_SOURCE_DIR}/src

)

if (${USE_CPP11})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_STANDARD 11)
link_directories(${LIBRARY_OUTPUT_PATH})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif()
message("CMAKE DEBUG: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")

add_executable(bench_mark
src/bench_mark_cpp.cc
src/bench_mark_c.cc
src/bench_mark.cc
src/bench_mark_utils.cc)

if (WIN32)
target_link_libraries(bench_mark Psapi)
endif()

add_subdirectory(bench_mark_src)
target_link_libraries(bench_mark tsfile)
57 changes: 0 additions & 57 deletions cpp/bench_mark/bench_mark_src/CMakeLists.txt

This file was deleted.

161 changes: 0 additions & 161 deletions cpp/bench_mark/bench_mark_src/bench_mark.cc

This file was deleted.

29 changes: 3 additions & 26 deletions cpp/bench_mark/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,10 @@
#

build_type=Debug
env_for_cyber=0
use_cpp11=1

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


if [ ${build_type} = "Debug" ]
then
mkdir -p build/Debug
cd build/Debug
use_sdk_debug=1
else
mkdir -p build/Release
cd build/Release
use_sdk_debug=0
fi

echo "use_sdk_debug=${use_sdk_debug}"
cmake ../../ \
-DUSE_SDK_DEBUG=$use_sdk_debug \
-DUSE_CPP11=$use_cpp11
cmake ../../
make
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@
* under the License.
*/

#ifndef TSFILE_BENCH_MARK_BENCH_CONF_H
#define TSFILE_BENCH_MARK_BENCH_CONF_H

#include <vector>

namespace bench {
int LOOP_NUM = 100000;
int THREAD_NUM = 1;
int TIMESERIES_NUM = 50;
std::vector<int> TYPE_LIST = {0, 0, 1, 0, 1};
static int tablet_num = 1000;
static int tag1_num = 1;
static int tag2_num = 10;
static int timestamp_per_tag = 1000;
static std::vector<int> field_type_vector = {1, 1, 1, 1, 1};
} // namespace bench

#endif // TSFILE_BENCH_MARK_BENCH_CONF_H
45 changes: 45 additions & 0 deletions cpp/bench_mark/src/bench_mark.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* License); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#include <iostream>
#include <string>

#include "bench_mark_c_cpp.h"

int main(int argc, char* argv[]) {
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " <cpp|c>" << std::endl;
return 1;
}

std::string mode(argv[1]);

if (mode == "cpp") {
bench_mark_cpp_write();
bench_mark_cpp_read();
} else if (mode == "c") {
bench_mark_c_write();
bench_mark_c_read();
} else {
std::cerr << "Invalid mode. Use 'cpp' or 'c'." << std::endl;
return 1;
}

return 0;
}
Loading
Loading