RigsofRods
Soft-body Physics Simulation
Macros | Enumerations | Functions | Variables
Bench_TruckParser_IdentifyKeyword.cpp File Reference
#include "benchmark/benchmark.h"
#include <regex>
#include <iostream>
+ Include dependency graph for Bench_TruckParser_IdentifyKeyword.cpp:

Go to the source code of this file.

Macros

#define E_DELIMITER_SPACE   "[[:blank:]]+"
 
#define DEFINE_REGEX_IGNORECASE(_NAME_, _REGEXP_)   const std::regex _NAME_ = std::regex( _REGEXP_, std::regex::ECMAScript | std::regex::icase);
 
#define E_KEYWORD_BLOCK(_NAME_)   "(^" _NAME_ "[[:blank:]]*$)?"
 A keyword which should be on it's own line. Used in IDENTIFY_KEYWORD. More...
 
#define E_KEYWORD_INLINE(_NAME_)   "(^" _NAME_ E_DELIMITER_SPACE ".*$)?"
 A keyword which should have values following it. Used in IDENTIFY_KEYWORD. More...
 
#define E_KEYWORD_INLINE_TOLERANT(_NAME_)   "(^" _NAME_ "[[:blank:],]+" ".*$)?"
 Inline keyword, tolerant version: keyword and values can be delimited by either space or comma. More...
 
#define IDENTIFY_KEYWORD_REGEX_STRING
 
#define stricmp   strcasecmp
 
#define strnicmp   strncasecmp
 
#define CASE(_LOWER_)   case(_LOWER_): case((_LOWER_)-32)
 
#define MATCH(_STR_, _KWORD_)   if (stricmp(line+1, _STR_+1) == 0) return _KWORD_;
 

Enumerations

enum  Keyword {
  KEYWORD_ADD_ANIMATION = 1, KEYWORD_AIRBRAKES, KEYWORD_ANIMATORS, KEYWORD_ANTI_LOCK_BRAKES,
  KEYWORD_AXLES, KEYWORD_AUTHOR, KEYWORD_BACKMESH, KEYWORD_BEAMS,
  KEYWORD_BRAKES, KEYWORD_CAB, KEYWORD_CAMERARAIL, KEYWORD_CAMERAS,
  KEYWORD_CINECAM, KEYWORD_COLLISIONBOXES, KEYWORD_COMMANDS, KEYWORD_COMMANDS2,
  KEYWORD_CONTACTERS, KEYWORD_CRUISECONTROL, KEYWORD_DESCRIPTION, KEYWORD_DETACHER_GROUP,
  KEYWORD_DISABLEDEFAULTSOUNDS, KEYWORD_ENABLE_ADVANCED_DEFORMATION, KEYWORD_END, KEYWORD_END_SECTION,
  KEYWORD_ENGINE, KEYWORD_ENGOPTION, KEYWORD_ENGTURBO, KEYWORD_ENVMAP,
  KEYWORD_EXHAUSTS, KEYWORD_EXTCAMERA, KEYWORD_FILEFORMATVERSION, KEYWORD_FILEINFO,
  KEYWORD_FIXES, KEYWORD_FLARES, KEYWORD_FLARES2, KEYWORD_FLEXBODIES,
  KEYWORD_FLEXBODY_CAMERA_MODE, KEYWORD_FLEXBODYWHEELS, KEYWORD_FORWARDCOMMANDS, KEYWORD_FUSEDRAG,
  KEYWORD_GLOBALS, KEYWORD_GUID, KEYWORD_GUISETTINGS, KEYWORD_HELP,
  KEYWORD_HIDE_IN_CHOOSER, KEYWORD_HOOKGROUP, KEYWORD_HOOKS, KEYWORD_HYDROS,
  KEYWORD_IMPORTCOMMANDS, KEYWORD_LOCKGROUPS, KEYWORD_LOCKGROUP_DEFAULT_NOLOCK, KEYWORD_MANAGEDMATERIALS,
  KEYWORD_MATERIALFLAREBINDINGS, KEYWORD_MESHWHEELS, KEYWORD_MESHWHEELS2, KEYWORD_MINIMASS,
  KEYWORD_NODECOLLISION, KEYWORD_NODES, KEYWORD_NODES2, KEYWORD_PARTICLES,
  KEYWORD_PISTONPROPS, KEYWORD_PROP_CAMERA_MODE, KEYWORD_PROPS, KEYWORD_RAILGROUPS,
  KEYWORD_RESCUER, KEYWORD_RIGIDIFIERS, KEYWORD_ROLLON, KEYWORD_ROPABLES,
  KEYWORD_ROPES, KEYWORD_ROTATORS, KEYWORD_ROTATORS2, KEYWORD_SCREWPROPS,
  KEYWORD_SECTION, KEYWORD_SECTIONCONFIG, KEYWORD_SET_BEAM_DEFAULTS, KEYWORD_SET_BEAM_DEFAULTS_SCALE,
  KEYWORD_SET_COLLISION_RANGE, KEYWORD_SET_INERTIA_DEFAULTS, KEYWORD_SET_MANAGEDMATERIALS_OPTIONS, KEYWORD_SET_NODE_DEFAULTS,
  KEYWORD_SET_SHADOWS, KEYWORD_SET_SKELETON_SETTINGS, KEYWORD_SHOCKS, KEYWORD_SHOCKS2,
  KEYWORD_SLIDENODE_CONNECT_INSTANTLY, KEYWORD_SLIDENODES, KEYWORD_SLOPE_BRAKE, KEYWORD_SOUNDSOURCES,
  KEYWORD_SOUNDSOURCES2, KEYWORD_SPEEDLIMITER, KEYWORD_SUBMESH, KEYWORD_SUBMESH_GROUNDMODEL,
  KEYWORD_TEXCOORDS, KEYWORD_TIES, KEYWORD_TORQUECURVE, KEYWORD_TRACTION_CONTROL,
  KEYWORD_TRIGGERS, KEYWORD_TURBOJETS, KEYWORD_TURBOPROPS, KEYWORD_TURBOPROPS2,
  KEYWORD_VIDEOCAMERA, KEYWORD_WHEELDETACHERS, KEYWORD_WHEELS, KEYWORD_WHEELS2,
  KEYWORD_WINGS, KEYWORD_INVALID = 0xFFFFFFFF
}
 

Functions

void PrepareBench_sol1 ()
 
unsigned FindKeywordMatch (std::smatch &search_results)
 
static void Bench_sol1__Regex (benchmark::State &state)
 
 BENCHMARK (Bench_sol1__Regex)
 
static void Bench_sol1b_RegexPreCond (benchmark::State &state)
 
 BENCHMARK (Bench_sol1b_RegexPreCond)
 
static void Bench_sol1c_RegexPreCondIsdigit (benchmark::State &state)
 
 BENCHMARK (Bench_sol1c_RegexPreCondIsdigit)
 
static void Bench_sol1d_RegexPreCondIsAlpha (benchmark::State &state)
 
 BENCHMARK (Bench_sol1d_RegexPreCondIsAlpha)
 
Keyword IdentifyKeywordSwitch (const char *line)
 
static void Bench_sol2__Switch (benchmark::State &state)
 
 BENCHMARK (Bench_sol2__Switch)
 
static void Bench_sol2b_SwitchPreCond (benchmark::State &state)
 
 BENCHMARK (Bench_sol2b_SwitchPreCond)
 
int main (int argc, char **argv)
 

Variables

const char * trucklines []
 
static int keyword
 
std::vector< std::string > lines_vec
 

Macro Definition Documentation

◆ CASE

#define CASE (   _LOWER_)    case(_LOWER_): case((_LOWER_)-32)

Definition at line 1654 of file Bench_TruckParser_IdentifyKeyword.cpp.

◆ DEFINE_REGEX_IGNORECASE

#define DEFINE_REGEX_IGNORECASE (   _NAME_,
  _REGEXP_ 
)    const std::regex _NAME_ = std::regex( _REGEXP_, std::regex::ECMAScript | std::regex::icase);

Definition at line 1454 of file Bench_TruckParser_IdentifyKeyword.cpp.

◆ E_DELIMITER_SPACE

#define E_DELIMITER_SPACE   "[[:blank:]]+"
#################### SOLUTION1 - REGEXES

Definition at line 1452 of file Bench_TruckParser_IdentifyKeyword.cpp.

◆ E_KEYWORD_BLOCK

#define E_KEYWORD_BLOCK (   _NAME_)    "(^" _NAME_ "[[:blank:]]*$)?"

A keyword which should be on it's own line. Used in IDENTIFY_KEYWORD.

Definition at line 1458 of file Bench_TruckParser_IdentifyKeyword.cpp.

◆ E_KEYWORD_INLINE

#define E_KEYWORD_INLINE (   _NAME_)    "(^" _NAME_ E_DELIMITER_SPACE ".*$)?"

A keyword which should have values following it. Used in IDENTIFY_KEYWORD.

Definition at line 1462 of file Bench_TruckParser_IdentifyKeyword.cpp.

◆ E_KEYWORD_INLINE_TOLERANT

#define E_KEYWORD_INLINE_TOLERANT (   _NAME_)    "(^" _NAME_ "[[:blank:],]+" ".*$)?"

Inline keyword, tolerant version: keyword and values can be delimited by either space or comma.

Definition at line 1466 of file Bench_TruckParser_IdentifyKeyword.cpp.

◆ IDENTIFY_KEYWORD_REGEX_STRING

#define IDENTIFY_KEYWORD_REGEX_STRING

Definition at line 1470 of file Bench_TruckParser_IdentifyKeyword.cpp.

◆ MATCH

#define MATCH (   _STR_,
  _KWORD_ 
)    if (stricmp(line+1, _STR_+1) == 0) return _KWORD_;

Definition at line 1656 of file Bench_TruckParser_IdentifyKeyword.cpp.

◆ stricmp

#define stricmp   strcasecmp

Definition at line 1649 of file Bench_TruckParser_IdentifyKeyword.cpp.

◆ strnicmp

#define strnicmp   strncasecmp

Definition at line 1650 of file Bench_TruckParser_IdentifyKeyword.cpp.

Enumeration Type Documentation

◆ Keyword

enum Keyword
Enumerator
KEYWORD_ADD_ANIMATION 
KEYWORD_AIRBRAKES 
KEYWORD_ANIMATORS 
KEYWORD_ANTI_LOCK_BRAKES 
KEYWORD_AXLES 
KEYWORD_AUTHOR 
KEYWORD_BACKMESH 
KEYWORD_BEAMS 
KEYWORD_BRAKES 
KEYWORD_CAB 
KEYWORD_CAMERARAIL 
KEYWORD_CAMERAS 
KEYWORD_CINECAM 
KEYWORD_COLLISIONBOXES 
KEYWORD_COMMANDS 
KEYWORD_COMMANDS2 
KEYWORD_CONTACTERS 
KEYWORD_CRUISECONTROL 
KEYWORD_DESCRIPTION 
KEYWORD_DETACHER_GROUP 
KEYWORD_DISABLEDEFAULTSOUNDS 
KEYWORD_ENABLE_ADVANCED_DEFORMATION 
KEYWORD_END 
KEYWORD_END_SECTION 
KEYWORD_ENGINE 
KEYWORD_ENGOPTION 
KEYWORD_ENGTURBO 
KEYWORD_ENVMAP 
KEYWORD_EXHAUSTS 
KEYWORD_EXTCAMERA 
KEYWORD_FILEFORMATVERSION 
KEYWORD_FILEINFO 
KEYWORD_FIXES 
KEYWORD_FLARES 
KEYWORD_FLARES2 
KEYWORD_FLEXBODIES 
KEYWORD_FLEXBODY_CAMERA_MODE 
KEYWORD_FLEXBODYWHEELS 
KEYWORD_FORWARDCOMMANDS 
KEYWORD_FUSEDRAG 
KEYWORD_GLOBALS 
KEYWORD_GUID 
KEYWORD_GUISETTINGS 
KEYWORD_HELP 
KEYWORD_HIDE_IN_CHOOSER 
KEYWORD_HOOKGROUP 
KEYWORD_HOOKS 
KEYWORD_HYDROS 
KEYWORD_IMPORTCOMMANDS 
KEYWORD_LOCKGROUPS 
KEYWORD_LOCKGROUP_DEFAULT_NOLOCK 
KEYWORD_MANAGEDMATERIALS 
KEYWORD_MATERIALFLAREBINDINGS 
KEYWORD_MESHWHEELS 
KEYWORD_MESHWHEELS2 
KEYWORD_MINIMASS 
KEYWORD_NODECOLLISION 
KEYWORD_NODES 
KEYWORD_NODES2 
KEYWORD_PARTICLES 
KEYWORD_PISTONPROPS 
KEYWORD_PROP_CAMERA_MODE 
KEYWORD_PROPS 
KEYWORD_RAILGROUPS 
KEYWORD_RESCUER 
KEYWORD_RIGIDIFIERS 
KEYWORD_ROLLON 
KEYWORD_ROPABLES 
KEYWORD_ROPES 
KEYWORD_ROTATORS 
KEYWORD_ROTATORS2 
KEYWORD_SCREWPROPS 
KEYWORD_SECTION 
KEYWORD_SECTIONCONFIG 
KEYWORD_SET_BEAM_DEFAULTS 
KEYWORD_SET_BEAM_DEFAULTS_SCALE 
KEYWORD_SET_COLLISION_RANGE 
KEYWORD_SET_INERTIA_DEFAULTS 
KEYWORD_SET_MANAGEDMATERIALS_OPTIONS 
KEYWORD_SET_NODE_DEFAULTS 
KEYWORD_SET_SHADOWS 
KEYWORD_SET_SKELETON_SETTINGS 
KEYWORD_SHOCKS 
KEYWORD_SHOCKS2 
KEYWORD_SLIDENODE_CONNECT_INSTANTLY 
KEYWORD_SLIDENODES 
KEYWORD_SLOPE_BRAKE 
KEYWORD_SOUNDSOURCES 
KEYWORD_SOUNDSOURCES2 
KEYWORD_SPEEDLIMITER 
KEYWORD_SUBMESH 
KEYWORD_SUBMESH_GROUNDMODEL 
KEYWORD_TEXCOORDS 
KEYWORD_TIES 
KEYWORD_TORQUECURVE 
KEYWORD_TRACTION_CONTROL 
KEYWORD_TRIGGERS 
KEYWORD_TURBOJETS 
KEYWORD_TURBOPROPS 
KEYWORD_TURBOPROPS2 
KEYWORD_VIDEOCAMERA 
KEYWORD_WHEELDETACHERS 
KEYWORD_WHEELS 
KEYWORD_WHEELS2 
KEYWORD_WINGS 
KEYWORD_INVALID 

Definition at line 6 of file Bench_TruckParser_IdentifyKeyword.cpp.

Function Documentation

◆ Bench_sol1__Regex()

static void Bench_sol1__Regex ( benchmark::State &  state)
static

Definition at line 1556 of file Bench_TruckParser_IdentifyKeyword.cpp.

+ Here is the call graph for this function:

◆ Bench_sol1b_RegexPreCond()

static void Bench_sol1b_RegexPreCond ( benchmark::State &  state)
static

Definition at line 1571 of file Bench_TruckParser_IdentifyKeyword.cpp.

+ Here is the call graph for this function:

◆ Bench_sol1c_RegexPreCondIsdigit()

static void Bench_sol1c_RegexPreCondIsdigit ( benchmark::State &  state)
static

Definition at line 1596 of file Bench_TruckParser_IdentifyKeyword.cpp.

+ Here is the call graph for this function:

◆ Bench_sol1d_RegexPreCondIsAlpha()

static void Bench_sol1d_RegexPreCondIsAlpha ( benchmark::State &  state)
static

Definition at line 1621 of file Bench_TruckParser_IdentifyKeyword.cpp.

+ Here is the call graph for this function:

◆ Bench_sol2__Switch()

static void Bench_sol2__Switch ( benchmark::State &  state)
static

Definition at line 1809 of file Bench_TruckParser_IdentifyKeyword.cpp.

+ Here is the call graph for this function:

◆ Bench_sol2b_SwitchPreCond()

static void Bench_sol2b_SwitchPreCond ( benchmark::State &  state)
static

Definition at line 1822 of file Bench_TruckParser_IdentifyKeyword.cpp.

+ Here is the call graph for this function:

◆ BENCHMARK() [1/6]

BENCHMARK ( Bench_sol1__Regex  )

◆ BENCHMARK() [2/6]

BENCHMARK ( Bench_sol1b_RegexPreCond  )

◆ BENCHMARK() [3/6]

◆ BENCHMARK() [4/6]

◆ BENCHMARK() [5/6]

BENCHMARK ( Bench_sol2__Switch  )

◆ BENCHMARK() [6/6]

BENCHMARK ( Bench_sol2b_SwitchPreCond  )

◆ FindKeywordMatch()

unsigned FindKeywordMatch ( std::smatch &  search_results)

Definition at line 1539 of file Bench_TruckParser_IdentifyKeyword.cpp.

+ Here is the caller graph for this function:

◆ IdentifyKeywordSwitch()

Keyword IdentifyKeywordSwitch ( const char *  line)

Definition at line 1658 of file Bench_TruckParser_IdentifyKeyword.cpp.

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1844 of file Bench_TruckParser_IdentifyKeyword.cpp.

+ Here is the call graph for this function:

◆ PrepareBench_sol1()

void PrepareBench_sol1 ( )

Definition at line 1530 of file Bench_TruckParser_IdentifyKeyword.cpp.

+ Here is the caller graph for this function:

Variable Documentation

◆ keyword

int keyword
static

Definition at line 1448 of file Bench_TruckParser_IdentifyKeyword.cpp.

◆ lines_vec

std::vector<std::string> lines_vec

Definition at line 1526 of file Bench_TruckParser_IdentifyKeyword.cpp.

◆ trucklines

const char* trucklines[]

Definition at line 65 of file Bench_TruckParser_IdentifyKeyword.cpp.