mirror of
https://github.com/biojppm/rapidyaml.git
synced 2026-01-18 21:41:18 +01:00
adding benchmarks
This commit is contained in:
@@ -59,6 +59,7 @@ cmake -DCMAKE_C_COMPILER=$CC_ -DCMAKE_C_FLAGS="$CFLAGS_" \
|
||||
-DCMAKE_CXX_COMPILER=$CXX_ -DCMAKE_CXX_FLAGS="$XFLAGS_" \
|
||||
-DCMAKE_BUILD_TYPE=$BT \
|
||||
-DRYML_DEV=ON \
|
||||
-DRYML_BUILD_BENCHMARKS=OFF \
|
||||
$CMFLAGS \
|
||||
$RYML_DIR
|
||||
make help | sed 1d | sort
|
||||
|
||||
@@ -59,6 +59,23 @@ if(RYML_DBG)
|
||||
target_compile_definitions(ryml PRIVATE RYML_DBG)
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------
|
||||
if(RYML_BUILD_TESTS OR RYML_BUILD_BENCHMARKS)
|
||||
# extern libraries
|
||||
set(ryml_ext_dir ${CMAKE_CURRENT_BINARY_DIR}/extern)
|
||||
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
||||
c4_import_remote_proj(ryml libyaml ${ryml_ext_dir}/libyaml
|
||||
GIT_REPOSITORY https://github.com/yaml/libyaml
|
||||
GIT_TAG master
|
||||
)
|
||||
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
|
||||
c4_import_remote_proj(ryml yaml-cpp ${ryml_ext_dir}/yaml-cpp
|
||||
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp
|
||||
GIT_TAG master
|
||||
)
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------
|
||||
if(RYML_BUILD_TESTS)
|
||||
enable_testing()
|
||||
@@ -67,5 +84,5 @@ endif()
|
||||
|
||||
#-------------------------------------------------------
|
||||
if(RYML_BUILD_BENCHMARKS)
|
||||
#
|
||||
add_subdirectory(bm bm)
|
||||
endif()
|
||||
|
||||
38
bm/CMakeLists.txt
Normal file
38
bm/CMakeLists.txt
Normal file
@@ -0,0 +1,38 @@
|
||||
c4_setup_benchmarks(ryml)
|
||||
|
||||
c4_import_remote_proj(ryml c4fs ${ryml_ext_dir}/c4fs
|
||||
GIT_REPOSITORY https://github.com/biojppm/c4fs
|
||||
GIT_TAG master)
|
||||
|
||||
function(ryml_add_bm bm_name case_file)
|
||||
set(bm ryml-benchmark-${bm_name})
|
||||
if(NOT TARGET ${bm})
|
||||
c4_add_executable(RYML ${bm}
|
||||
SOURCES ${bm_name}.cpp ${ARGN}
|
||||
LIBS ryml yaml yaml-cpp benchmark c4fs
|
||||
FOLDER ryml-benchmark)
|
||||
if(RYML_DBG)
|
||||
target_compile_definitions(${bm} PRIVATE RYML_DBG)
|
||||
endif()
|
||||
endif()
|
||||
set(rdir ${CMAKE_CURRENT_BINARY_DIR}/bm_results)
|
||||
get_filename_component(case ${case_file} NAME_WE)
|
||||
set(rt ${bm}-${case})
|
||||
set(rf ${rdir}/${bm_name}-${case}.json)
|
||||
print_var(bm)
|
||||
print_var(rt)
|
||||
print_var(rf)
|
||||
if(NOT EXISTS ${rdir})
|
||||
file(MAKE_DIRECTORY ${rdir})
|
||||
endif()
|
||||
c4_add_benchmark(RYML ${bm} ${rt} ${rdir} "${rt}: results are in ${rf}"
|
||||
--benchmark_out_format=json --benchmark_out=${rf} ${case_file})
|
||||
endfunction()
|
||||
|
||||
set(cdir "${CMAKE_CURRENT_LIST_DIR}/cases")
|
||||
file(GLOB bm_cases RELATIVE "${cdir}" "${cdir}/*.*")
|
||||
print_var(bm_cases)
|
||||
foreach(case_file ${bm_cases})
|
||||
print_var(case_file)
|
||||
ryml_add_bm(parse "${cdir}/${case_file}")
|
||||
endforeach()
|
||||
90
bm/cases/appveyor.yml
Normal file
90
bm/cases/appveyor.yml
Normal file
@@ -0,0 +1,90 @@
|
||||
version: '{build}'
|
||||
|
||||
image: Visual Studio 2017
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
|
||||
- compiler: msvc-15-seh
|
||||
generator: "Visual Studio 15 2017"
|
||||
configuration: Debug
|
||||
|
||||
- compiler: msvc-15-seh
|
||||
generator: "Visual Studio 15 2017 Win64"
|
||||
configuration: Debug
|
||||
|
||||
- compiler: msvc-15-seh
|
||||
generator: "Visual Studio 15 2017"
|
||||
configuration: Release
|
||||
|
||||
- compiler: msvc-15-seh
|
||||
generator: "Visual Studio 15 2017 Win64"
|
||||
configuration: Release
|
||||
|
||||
|
||||
- compiler: msvc-14-seh
|
||||
generator: "Visual Studio 14 2015"
|
||||
configuration: Debug
|
||||
|
||||
- compiler: msvc-14-seh
|
||||
generator: "Visual Studio 14 2015 Win64"
|
||||
configuration: Debug
|
||||
|
||||
- compiler: msvc-14-seh
|
||||
generator: "Visual Studio 14 2015"
|
||||
configuration: Release
|
||||
|
||||
- compiler: msvc-14-seh
|
||||
generator: "Visual Studio 14 2015 Win64"
|
||||
configuration: Release
|
||||
|
||||
|
||||
|
||||
#- compiler: gcc-5.3.0-posix
|
||||
# generator: "MinGW Makefiles"
|
||||
# cxx_path: 'C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin'
|
||||
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
# configuration: Quicktest
|
||||
# externconfig: Debug
|
||||
# cmkargs: "-DC4STL_PEDANTIC=ON -DC4STL_WERROR=ON"
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
install:
|
||||
- git submodule update --init --recursive
|
||||
# git bash conflicts with MinGW makefiles
|
||||
- if "%generator%"=="MinGW Makefiles" (set "PATH=%PATH:C:\Program Files\Git\usr\bin;=%")
|
||||
- if not "%cxx_path%"=="" (set "PATH=%PATH%;%cxx_path%")
|
||||
|
||||
build_script:
|
||||
- md _build -Force
|
||||
- cd _build
|
||||
|
||||
test_script:
|
||||
- echo %configuration%
|
||||
- cmake -G "%generator%" "-DCMAKE_BUILD_TYPE=%configuration%" -DRYML_DEV=ON ..
|
||||
- dir
|
||||
- dir test
|
||||
- cmake --build . --config %configuration% --target ryml-test
|
||||
#- ctest -c %configuration% --timeout 300 --output-on-failure
|
||||
|
||||
artifacts:
|
||||
- path: '_build/CMakeFiles/*.log'
|
||||
name: logs
|
||||
- path: '_build/Testing/**/*.xml'
|
||||
name: test_results
|
||||
|
||||
skip_commits:
|
||||
files:
|
||||
- .gitignore
|
||||
- .travis*
|
||||
- .ci/travis*
|
||||
- .ci/dev_*
|
||||
- .ci/show_*
|
||||
- .ci/vagrant*
|
||||
- .ci/Vagrant*
|
||||
- bm/html/*
|
||||
- doc/*
|
||||
- LICENSE.txt
|
||||
- README.*
|
||||
107
bm/cases/travis.yml
Normal file
107
bm/cases/travis.yml
Normal file
@@ -0,0 +1,107 @@
|
||||
sudo: required
|
||||
dist: trusty
|
||||
language: cpp
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
# - llvm-toolchain-trusty
|
||||
|
||||
# we're not using combination parameters here to ensure that the builds
|
||||
# run in the order we want. (We want to perform the fastest tests first so
|
||||
# failed tests appear as early as possible).
|
||||
env:
|
||||
global:
|
||||
- PATH=/usr/local/bin:$PATH
|
||||
|
||||
# NOTE: The compiler setting is unused. It simply makes the display on
|
||||
# travis-ci.org more readable.
|
||||
# WARNING: do not use the name CXX. Travis will ignore the value here.
|
||||
matrix:
|
||||
|
||||
include:
|
||||
#
|
||||
# ----------- Coverage (covers all tests, slow) -------------------------
|
||||
#
|
||||
- env: CXX_=g++-7 A=64 BT=Coverage
|
||||
- env: CXX_=g++-7 A=32 BT=Coverage
|
||||
#
|
||||
# ----------- other tests -----------------------------------------------
|
||||
#
|
||||
#- env: CXX_=clang++-7 A=32 BT=Debug SAN=ALL VG=ON
|
||||
#- env: CXX_=clang++-7 A=64 BT=Debug SAN=ALL VG=ON
|
||||
#- env: CXX_=clang++-7 A=32 BT=Release SAN=ALL VG=ON
|
||||
#- env: CXX_=clang++-7 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
- env: CXX_=g++-7 A=32 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=g++-7 A=64 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=g++-7 A=32 BT=Release SAN=ALL VG=ON
|
||||
- env: CXX_=g++-7 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
- env: CXX_=clang++-6.0 A=32 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-6.0 A=64 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-6.0 A=32 BT=Release SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-6.0 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
- env: CXX_=clang++-5.0 A=32 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-5.0 A=64 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-5.0 A=32 BT=Release SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-5.0 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
- env: CXX_=clang++-4.0 A=32 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-4.0 A=64 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-4.0 A=32 BT=Release SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-4.0 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
- env: CXX_=clang++-3.9 A=32 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.9 A=64 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.9 A=32 BT=Release SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.9 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
- env: CXX_=g++-6 A=32 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=g++-6 A=64 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=g++-6 A=32 BT=Release SAN=ALL VG=ON
|
||||
- env: CXX_=g++-6 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
- env: CXX_=clang++-3.8 A=32 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.8 A=64 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.8 A=32 BT=Release SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.8 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
- env: CXX_=g++-5 A=32 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=g++-5 A=64 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=g++-5 A=32 BT=Release SAN=ALL VG=ON
|
||||
- env: CXX_=g++-5 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
- env: CXX_=clang++-3.7 A=32 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.7 A=64 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.7 A=32 BT=Release SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.7 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
#- env: CXX_=g++-4.9 A=32 BT=Debug SAN=ALL VG=ON
|
||||
#- env: CXX_=g++-4.9 A=64 BT=Debug SAN=ALL VG=ON
|
||||
#- env: CXX_=g++-4.9 A=32 BT=Release SAN=ALL VG=ON
|
||||
#- env: CXX_=g++-4.9 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
- env: CXX_=clang++-3.6 A=32 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.6 A=64 BT=Debug SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.6 A=32 BT=Release SAN=ALL VG=ON
|
||||
- env: CXX_=clang++-3.6 A=64 BT=Release SAN=ALL VG=ON
|
||||
|
||||
# ----------- clang-tidy
|
||||
#
|
||||
- env: CXX_=clang++-6.0 A=32 BT=Debug LINT=clang-tidy
|
||||
- env: CXX_=clang++-6.0 A=64 BT=Debug LINT=clang-tidy
|
||||
- env: CXX_=clang++-6.0 A=32 BT=Release LINT=clang-tidy
|
||||
- env: CXX_=clang++-6.0 A=64 BT=Release LINT=clang-tidy
|
||||
#
|
||||
|
||||
install:
|
||||
- bash -x .ci/travis-install.sh
|
||||
|
||||
script:
|
||||
- bash -x .ci/travis-test.sh
|
||||
|
||||
after_success:
|
||||
- echo "Success!"
|
||||
- bash -x .ci/travis-coverage.sh
|
||||
97
bm/parse.cpp
Normal file
97
bm/parse.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <ryml.hpp>
|
||||
#include <ryml_std.hpp>
|
||||
#include <c4/fs/fs.hpp>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace bm = benchmark;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct Case
|
||||
{
|
||||
c4::csubstr filename;
|
||||
std::vector<char> src;
|
||||
std::vector<char> in_place;
|
||||
bool is_json;
|
||||
ryml::Tree ryml_tree;
|
||||
|
||||
void load(const char* file)
|
||||
{
|
||||
filename = c4::to_csubstr(file);
|
||||
is_json = filename.ends_with(".json");
|
||||
src = c4::fs::file_get_contents<std::vector<char>>(file);
|
||||
in_place = src;
|
||||
}
|
||||
|
||||
};
|
||||
Case c;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ryml_parse_rw(bm::State& st)
|
||||
{
|
||||
for(auto _ : st)
|
||||
{
|
||||
ryml::Tree tree = ryml::parse(c.filename, to_substr(c.in_place));
|
||||
}
|
||||
}
|
||||
|
||||
void ryml_parse_rw_reuse(bm::State& st)
|
||||
{
|
||||
for(auto _ : st)
|
||||
{
|
||||
parse(c.filename, to_substr(c.in_place), &c.ryml_tree);
|
||||
}
|
||||
}
|
||||
|
||||
void ryml_parse_ro(bm::State& st)
|
||||
{
|
||||
for(auto _ : st)
|
||||
{
|
||||
ryml::Tree tree = ryml::parse(c.filename, to_csubstr(c.src));
|
||||
}
|
||||
}
|
||||
|
||||
void ryml_parse_ro_reuse(bm::State& st)
|
||||
{
|
||||
for(auto _ : st)
|
||||
{
|
||||
parse(c.filename, to_csubstr(c.src), &c.ryml_tree);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(ryml_parse_ro);
|
||||
BENCHMARK(ryml_parse_ro_reuse);
|
||||
BENCHMARK(ryml_parse_rw);
|
||||
BENCHMARK(ryml_parse_rw_reuse);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void print(const char* ctx, int argc, char** argv)
|
||||
{
|
||||
std::cout << ctx << ": " << "argc=" << argc << "\n";
|
||||
for(int i = 0; i < argc; ++i)
|
||||
std::cout << ctx << ": " << "argv[" << i << "]=" << argv[i] << "\n";
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
print("before", argc, argv);
|
||||
bm::Initialize(&argc, argv);
|
||||
print("after", argc, argv);
|
||||
std::cout << "argc==2: " << argc << " " << (argc==2) << "\n";
|
||||
C4_ASSERT(argc == 2);
|
||||
c.load(argv[1]);
|
||||
bm::RunSpecifiedBenchmarks();
|
||||
}
|
||||
2
extern/c4core
vendored
2
extern/c4core
vendored
Submodule extern/c4core updated: 0c5e770d0e...755dfc56bf
@@ -1,30 +1,5 @@
|
||||
c4_setup_testing(ryml)
|
||||
|
||||
# a test suite for YAML
|
||||
c4_download_remote_proj(ryml yaml-test-suite ${CMAKE_CURRENT_BINARY_DIR}/extern/yaml-test-suite
|
||||
GIT_REPOSITORY https://github.com/yaml/yaml-test-suite
|
||||
GIT_TAG master
|
||||
)
|
||||
|
||||
# extern libraries
|
||||
|
||||
set(ryml_ext_dir ${CMAKE_CURRENT_BINARY_DIR}/extern)
|
||||
|
||||
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
||||
c4_import_remote_proj(ryml libyaml ${ryml_ext_dir}/libyaml
|
||||
GIT_REPOSITORY https://github.com/yaml/libyaml
|
||||
GIT_TAG master
|
||||
)
|
||||
|
||||
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
|
||||
c4_import_remote_proj(ryml yaml-cpp ${ryml_ext_dir}/yaml-cpp
|
||||
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp
|
||||
GIT_TAG master
|
||||
)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
c4_add_library(RYML ryml_util_test
|
||||
SOURCES test_case.hpp test_case.cpp
|
||||
INC_DIRS ${CMAKE_CURRENT_LIST_DIR} ${ryml_ext_dir}/yaml-cpp/src/include
|
||||
|
||||
Reference in New Issue
Block a user