Skip to content

Commit

Permalink
Performance enhancements + CSVFormat interface changes (#37)
Browse files Browse the repository at this point in the history
## Public API changes

* Performance increased from ~200MB/s to ~220MB/s
* Made `CSVFormat` more readable and user-friendly

## Behind the scenes

 * Resolved #34 by storing all CSV row data in contiguous memory regions
 * Modified CMake to improve developer experience
 * Simplified CSVRow constructors/definition
 * Simplified CSVReader::write_record logic
 * Various other code clean-up actions
  • Loading branch information
vincentlaucsb authored May 19, 2019
1 parent d52f177 commit b565755
Show file tree
Hide file tree
Showing 40 changed files with 2,208 additions and 1,298 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Custom Settigns
CMakeLists2.txt

# Build
bin/
build/

# Doxygen
docs/html
*.tmp

# Visual Studio
Debug/
Release/
.vs/
*.pdb
*.i*
Expand Down
30 changes: 23 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
cmake_minimum_required(VERSION 3.9)
project(csv_parser)
project(csv)

set(CMAKE_CXX_STANDARD 17)
if(CSV_CXX_STANDARD)
set(CMAKE_CXX_STANDARD ${CSV_CXX_STANDARD})
else()
set(CMAKE_CXX_STANDARD 17)
endif(CSV_CXX_STANDARD)

message("Building CSV library using C++${CMAKE_CXX_STANDARD}")
add_compile_definitions(CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD})

if (MSVC)
if(MSVC)
# Make Visual Studio report accurate C++ version
# See: https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
set(CMAKE_CXX_FLAGS "/EHsc /Zc:__cplusplus")
Expand All @@ -12,24 +19,33 @@ if (MSVC)
# /Wall emits warnings about the C++ standard library
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif(CMAKE_BUILD_TYPE MATCHES Debug)

else()
set(CMAKE_CXX_FLAGS "-pthread")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -lgcov --coverage")
# Ignore Visual Studio pragma regions
set(CMAKE_CXX_FLAGS "-pthread -Wno-unknown-pragmas")
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -g")
endif(CMAKE_BUILD_TYPE MATCHES Debug)
endif(MSVC)

set(CSV_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
set(CSV_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(CSV_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/)
set(CSV_SOURCE_DIR ${CSV_INCLUDE_DIR}/internal/)
set(CSV_TEST_DIR ${CMAKE_CURRENT_LIST_DIR}/tests)

include_directories(${CSV_INCLUDE_DIR})

## Load developer specific CMake settings
include(CMakeLists2.txt OPTIONAL)

## Main Library
add_subdirectory(${CSV_SOURCE_DIR})

## Executables
add_subdirectory("programs")

## Tests
enable_testing()
add_subdirectory("tests")
8 changes: 4 additions & 4 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"buildRoot": "${projectDir}\\build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
Expand All @@ -20,8 +20,8 @@
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"buildRoot": "${projectDir}\\build\\${name}",
"installRoot": "{projectDir}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
Expand Down
Loading

0 comments on commit b565755

Please sign in to comment.