| 1 | #! /usr/bin/perl | ||||||||||||||||||||||||||||||
| 2 | # PODNAME: benchmarkanything-storage | ||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: BenchmarkAnything storage cmdline tool | ||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use 5.008; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use App::Rad; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||
| 11 | ###################################################################### | ||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||
| 13 | # App::Rad interface | ||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||
| 15 | ###################################################################### | ||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||
| 17 | 4 | App::Rad->run(); | |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||
| 19 | sub setup | ||||||||||||||||||||||||||||||
| 20 | { | ||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | my $c = shift; | ||||||||||||||||||||||||||||
|
Subroutine
setup: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 22 | 4 | $c->unregister_command("help"); | |||||||||||||||||||||||||||||
| 23 | 4 | $c->register_commands("help", "search", "add", "createdb", "listnames", "listkeys", "stats", "processqueue", "initsearch", "syncsearch", "gc", "init"); | |||||||||||||||||||||||||||||
| 24 | 4 | $c->register('search-sync' => \&syncsearch); | |||||||||||||||||||||||||||||
| 25 | 4 | $c->register('search-init' => \&initsearch); | |||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||
| 28 | sub teardown | ||||||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | my $c = shift; | ||||||||||||||||||||||||||||
|
Subroutine
teardown: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | _disconnect($c) unless $c->cmd =~ /^init|help$/; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||
| 35 | sub help | ||||||||||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
help: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||
| 39 | 0 | return qq{benchmarkanything-storage | |||||||||||||||||||||||||||||
| 40 | [-i|--intype <TYPE>] | ||||||||||||||||||||||||||||||
| 41 | [-o|--outtype <TYPE>] | ||||||||||||||||||||||||||||||
| 42 | [-s|--separator <SEPARATOR>] | ||||||||||||||||||||||||||||||
| 43 | [--fb] | ||||||||||||||||||||||||||||||
| 44 | [--fi] | ||||||||||||||||||||||||||||||
| 45 | [-c|--cfgfile <FILE>] | ||||||||||||||||||||||||||||||
| 46 | [--debug] | ||||||||||||||||||||||||||||||
| 47 | [-d|--data] | ||||||||||||||||||||||||||||||
| 48 | [-f|--force] | ||||||||||||||||||||||||||||||
| 49 | [-v|--verbose] | ||||||||||||||||||||||||||||||
| 50 | [--skipvalidation] | ||||||||||||||||||||||||||||||
| 51 | [--queuemode] | ||||||||||||||||||||||||||||||
| 52 | [--startid <VALUE_ID>] | ||||||||||||||||||||||||||||||
| 53 | [--bulkcount <COUNT>] | ||||||||||||||||||||||||||||||
| 54 | [-p|--pattern <PATTERN>] | ||||||||||||||||||||||||||||||
| 55 | [--id <VALUE_ID>] | ||||||||||||||||||||||||||||||
| 56 | [--really <DSN>] | ||||||||||||||||||||||||||||||
| 57 | [init|search|add|createdb|listnames|listkeys|stats|processqueue|search-init|search-sync|gc] | ||||||||||||||||||||||||||||||
| 58 | <DATAFILE> | ||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||
| 60 | Sub commands: | ||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||
| 62 | init - Initialize a local BenchmarkAnything setup. | ||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||
| 64 | search - Search BenchmarkAnything data. | ||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||
| 66 | add - Add one or more BenchmarkAnything entries. | ||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||
| 68 | createdb - Drop and create tables in the backend store. | ||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||
| 70 | listnames - List existing metric names. | ||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||
| 72 | listkeys - List existing additional key names. | ||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||
| 74 | stats - Show counts of data points, metrics, keys, etc. | ||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||
| 76 | processqueue - Works on the result queue created by add --queuemode. | ||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||
| 78 | search-init - Initializes the configured search engine (Elasticsearch). | ||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||
| 80 | search-sync - Syncs the DB with the configured search engine (Elasticsearch). | ||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||
| 82 | gc - Garbage collects artefacts in the backend store. | ||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||
| 85 | Options: | ||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||
| 87 | -i | ||||||||||||||||||||||||||||||
| 88 | --intype - input format | ||||||||||||||||||||||||||||||
| 89 | [json(default), yaml, dumper] | ||||||||||||||||||||||||||||||
| 90 | -o | ||||||||||||||||||||||||||||||
| 91 | --outtype - output format | ||||||||||||||||||||||||||||||
| 92 | [json(default), yaml, dumper] | ||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||
| 94 | -s | ||||||||||||||||||||||||||||||
| 95 | --separator - sub entry separator for output format 'flat' | ||||||||||||||||||||||||||||||
| 96 | (default=;) | ||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||
| 98 | --fb - on output format 'flat' use [brackets] around | ||||||||||||||||||||||||||||||
| 99 | outer arrays | ||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||
| 101 | --fi - on output format 'flat' prefix outer array lines | ||||||||||||||||||||||||||||||
| 102 | with index | ||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||
| 104 | -c | ||||||||||||||||||||||||||||||
| 105 | --cfgfile - config file for storage backend | ||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||
| 107 | -p | ||||||||||||||||||||||||||||||
| 108 | --pattern - pattern for 'listnames'/'listkeys' commands (using LIKE) | ||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||
| 110 | --id - search id for 'search' command. When given, | ||||||||||||||||||||||||||||||
| 111 | other queries are ignored and the result point | ||||||||||||||||||||||||||||||
| 112 | is returned with all additional key/value fields. | ||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||
| 114 | --queuemode - used for 'add' command; values are just enqueued | ||||||||||||||||||||||||||||||
| 115 | for later actual processing. This lets | ||||||||||||||||||||||||||||||
| 116 | 'add' return quicker, gives higher throughput. | ||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||
| 118 | -b | ||||||||||||||||||||||||||||||
| 119 | --backend - backend ['sql' (default)] | ||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||
| 121 | --debug - Pass through 'debug' option to used modules | ||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||
| 123 | --verbose - print what's going on | ||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||
| 125 | --force - Force the respective command | ||||||||||||||||||||||||||||||
| 126 | + for 'search-init' it means to delete and re-create the index | ||||||||||||||||||||||||||||||
| 127 | + for 'search-sync' it means to (re-)index all | ||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||
| 129 | --startid - Starting VALUE_ID for 'search-sync' (default 1). | ||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||
| 131 | --bulkcount - Chunk size for 'search-sync' (default 10000). | ||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||
| 133 | --skipvalidation - Disables schema validation checking, | ||||||||||||||||||||||||||||||
| 134 | usually for 'add' command. | ||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||
| 136 | --really - used for 'createdb' command. | ||||||||||||||||||||||||||||||
| 137 | Avoids the 'Are you sure?' question. You need to | ||||||||||||||||||||||||||||||
| 138 | provide the DSN from config that createdb would use, | ||||||||||||||||||||||||||||||
| 139 | to avoid painful mistakes. | ||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||
| 141 | -d | ||||||||||||||||||||||||||||||
| 142 | --data - Data [instead of DATAFILE]. | ||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||
| 144 | <DATAFILE> - input data file ("-" for STDIN) unless --data is given | ||||||||||||||||||||||||||||||
| 145 | Content depends on the sub command: | ||||||||||||||||||||||||||||||
| 146 | + for 'search' it is a search query | ||||||||||||||||||||||||||||||
| 147 | + for 'add' it is BenchmarkAnything data | ||||||||||||||||||||||||||||||
| 148 | + for 'createdb' no input data is used | ||||||||||||||||||||||||||||||
| 149 | }; | ||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||
| 152 | sub _connect | ||||||||||||||||||||||||||||||
| 153 | { | ||||||||||||||||||||||||||||||
| 154 | 4 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_connect: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||
| 156 | 4 | require BenchmarkAnything::Storage::Frontend::Lib; | |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||
| 158 | 4 | my $opt = $c->options; | |||||||||||||||||||||||||||||
| 159 | $c->{_balib} = BenchmarkAnything::Storage::Frontend::Lib->new | ||||||||||||||||||||||||||||||
| 160 | (cfgfile => $opt->{cfgfile}, | ||||||||||||||||||||||||||||||
| 161 | really => $opt->{really}, | ||||||||||||||||||||||||||||||
| 162 | debug => $opt->{debug}, | ||||||||||||||||||||||||||||||
| 163 | verbose => $opt->{verbose}, | ||||||||||||||||||||||||||||||
| 164 | skipvalidation => $opt->{skipvalidation}, | ||||||||||||||||||||||||||||||
| 165 | queuemode => $opt->{queuemode}, | ||||||||||||||||||||||||||||||
| 166 | 4 | ▶ | ($c->cmd =~ /^(init|help)$/ ? | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 167 | ( noconnect => 1, | ||||||||||||||||||||||||||||||
| 168 | noconfig => 1, | ||||||||||||||||||||||||||||||
| 169 | ) : ()), | ||||||||||||||||||||||||||||||
| 170 | ); | ||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||
| 173 | sub _disconnect | ||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||
| 175 | 2 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_disconnect: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||
| 177 | 2 | ▶ | $c->{_balib}->disconnect if $c->{_balib}; # balib is undef on getopt errors | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||
| 180 | sub _getopt | ||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||
| 182 | 8 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_getopt: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||
| 184 | 8 | ▶ | $c->getopt( "cfgfile|c=s", | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition25%1/4
$c->getopt('cfgfile|c=s', 'backend|b=s', 'intype|i=s', 'outtype|o=s', 'separator|s=s', 'fb', 'fi', 'pattern|p=s', 'id=s', 'debug', 'data|d=s', 'force|f', 'verbose|v', 'startid=i', 'bulkcount=i', 'skipvalidation', 'queuemode', 'really=s') || help() && (return undef)
help() and return undef
MC/DC0%0/2
$c->getopt('cfgfile|c=s', 'backend|b=s', 'intype|i=s', 'outtype|o=s', 'separator|s=s', 'fb', 'fi', 'pattern|p=s', 'id=s', 'debug', 'data|d=s', 'force|f', 'verbose|v', 'startid=i', 'bulkcount=i', 'skipvalidation', 'queuemode', 'really=s') || help() && (return undef)
$c->getopt('cfgfile|c=s', 'backend|b=s', 'intype|i=s', 'outtype|o=s', 'separator|s=s', 'fb', 'fi', 'pattern|p=s', 'id=s', 'debug', 'data|d=s', 'force|f', 'verbose|v', 'startid=i', 'bulkcount=i', 'skipvalidation', 'queuemode', 'really=s')
help()
Truth table33%1/3
A || B
A= $c->getopt('cfgfile|c=s', 'backend|b=s', 'intype|i=s', 'outtype|o=s', 'separator|s=s', 'fb', 'fi', 'pattern|p=s', 'id=s', 'debug', 'data|d=s', 'force|f', 'verbose|v', 'startid=i', 'bulkcount=i', 'skipvalidation', 'queuemode', 'really=s')B= help()
| |||||||||||||||||||||||||||||||
| 185 | "backend|b=s", | ||||||||||||||||||||||||||||||
| 186 | "intype|i=s", | ||||||||||||||||||||||||||||||
| 187 | "outtype|o=s", | ||||||||||||||||||||||||||||||
| 188 | "separator|s=s", | ||||||||||||||||||||||||||||||
| 189 | "fb", | ||||||||||||||||||||||||||||||
| 190 | "fi", | ||||||||||||||||||||||||||||||
| 191 | "pattern|p=s", | ||||||||||||||||||||||||||||||
| 192 | "id=s", | ||||||||||||||||||||||||||||||
| 193 | "debug", | ||||||||||||||||||||||||||||||
| 194 | "data|d=s", | ||||||||||||||||||||||||||||||
| 195 | "force|f", | ||||||||||||||||||||||||||||||
| 196 | "verbose|v", | ||||||||||||||||||||||||||||||
| 197 | "startid=i", | ||||||||||||||||||||||||||||||
| 198 | "bulkcount=i", | ||||||||||||||||||||||||||||||
| 199 | "skipvalidation", | ||||||||||||||||||||||||||||||
| 200 | "queuemode", | ||||||||||||||||||||||||||||||
| 201 | "really=s", | ||||||||||||||||||||||||||||||
| 202 | ) | ||||||||||||||||||||||||||||||
| 203 | or help() and return undef; | ||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||
| 205 | 4 | _connect($c); | |||||||||||||||||||||||||||||
| 206 | 4 | _set_defaults($c); | |||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||
| 210 | sub _set_defaults | ||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||
| 212 | 4 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_set_defaults: called CC=6 SCAR=18.8
| |||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||
| 214 | 4 | ▶ | $c->{_file} = $c->argv->[0] || '-'; | ||||||||||||||||||||||||||||
|
Condition100%2/2
$c->argv->[0] || '-'
MC/DC100%1/1
$c->argv->[0] || '-'
$c->argv->[0]
Truth table100%2/2
A
A= $c->argv->[0]
| |||||||||||||||||||||||||||||||
| 215 | 4 | ▶ | $c->options->{outtype} ||= 'json'; | ||||||||||||||||||||||||||||
|
Condition50%1/2
$c->options->{"outtype"} ||= "json"
MC/DC0%0/1
$c->options->{"outtype"} ||= "json"
$c->options->{"outtype"}
Truth table50%1/2
A
A= $c->options->{"outtype"}
| |||||||||||||||||||||||||||||||
| 216 | 4 | ▶ | $c->options->{separator} ||= ';'; | ||||||||||||||||||||||||||||
|
Condition50%1/2
$c->options->{"separator"} ||= ";"
MC/DC0%0/1
$c->options->{"separator"} ||= ";"
$c->options->{"separator"}
Truth table50%1/2
A
A= $c->options->{"separator"}
| |||||||||||||||||||||||||||||||
| 217 | 4 | ▶ | $c->options->{fb} ||= 0; | ||||||||||||||||||||||||||||
|
Condition50%1/2
$c->options->{"fb"} ||= 0
MC/DC0%0/1
$c->options->{"fb"} ||= 0
$c->options->{"fb"}
Truth table50%1/2
A
A= $c->options->{"fb"}
| |||||||||||||||||||||||||||||||
| 218 | 4 | ▶ | $c->options->{fi} ||= 0; | ||||||||||||||||||||||||||||
|
Condition50%1/2
$c->options->{"fi"} ||= 0
MC/DC0%0/1
$c->options->{"fi"} ||= 0
$c->options->{"fi"}
Truth table50%1/2
A
A= $c->options->{"fi"}
| |||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||
| 222 | sub init :Help(Initialize a local BenchmarkAnything setup) | ||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||
| 226 | 0 | _getopt($c); | |||||||||||||||||||||||||||||
| 227 | 0 | _init($c); | |||||||||||||||||||||||||||||
| 228 | 4 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||
| 230 | sub search :Help(search BenchmarkAnything data) | ||||||||||||||||||||||||||||||
| 231 | { | ||||||||||||||||||||||||||||||
| 232 | 2 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
search: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||
| 234 | 2 | _getopt($c); | |||||||||||||||||||||||||||||
| 235 | 2 | _search($c); | |||||||||||||||||||||||||||||
| 236 | 4 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||
| 238 | sub add :Help(add one or more BenchmarkAnything entries) | ||||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||||
| 240 | 5 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||
| 242 | 5 | _getopt($c); | |||||||||||||||||||||||||||||
| 243 | 1 | _add($c); | |||||||||||||||||||||||||||||
| 244 | 4 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||
| 246 | sub createdb :Help(drop and create tables in the backend store) | ||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||
| 248 | 1 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
createdb: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||
| 250 | 1 | _getopt($c); | |||||||||||||||||||||||||||||
| 251 | 1 | _createdb($c); | |||||||||||||||||||||||||||||
| 252 | 4 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||
| 254 | sub listnames :Help(list existing metric names) | ||||||||||||||||||||||||||||||
| 255 | { | ||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
listnames: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||
| 258 | 0 | _getopt($c); | |||||||||||||||||||||||||||||
| 259 | 0 | _listnames($c); | |||||||||||||||||||||||||||||
| 260 | 4 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||
| 262 | sub listkeys :Help(list existing additional key names) | ||||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
listkeys: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||
| 266 | 0 | _getopt($c); | |||||||||||||||||||||||||||||
| 267 | 0 | _listkeys($c); | |||||||||||||||||||||||||||||
| 268 | 4 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||
| 270 | sub stats :Help(show backend storage usage counts) | ||||||||||||||||||||||||||||||
| 271 | { | ||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
stats: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||
| 274 | 0 | _getopt($c); | |||||||||||||||||||||||||||||
| 275 | 0 | _stats($c); | |||||||||||||||||||||||||||||
| 276 | 4 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||
| 278 | sub processqueue :Help(Works on the result queue created by add --queuemode) | ||||||||||||||||||||||||||||||
| 279 | { | ||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
processqueue: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||
| 282 | 0 | _getopt($c); | |||||||||||||||||||||||||||||
| 283 | 0 | _processqueue($c); | |||||||||||||||||||||||||||||
| 284 | 0 | _gc($c); | |||||||||||||||||||||||||||||
| 285 | 4 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||
| 287 | sub initsearch :Help(Initializes the configured search engine (Elasticsearch)) | ||||||||||||||||||||||||||||||
| 288 | { | ||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
initsearch: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||
| 291 | 0 | _getopt($c); | |||||||||||||||||||||||||||||
| 292 | 0 | _init_search_engine($c); | |||||||||||||||||||||||||||||
| 293 | 0 | _gc($c); | |||||||||||||||||||||||||||||
| 294 | 4 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||
| 296 | sub syncsearch :Help(Syncs the DB with the configured search engine (Elasticsearch)) | ||||||||||||||||||||||||||||||
| 297 | { | ||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
syncsearch: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||
| 300 | 0 | _getopt($c); | |||||||||||||||||||||||||||||
| 301 | 0 | _sync_search_engine($c); | |||||||||||||||||||||||||||||
| 302 | 0 | _gc($c); | |||||||||||||||||||||||||||||
| 303 | 4 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||
| 305 | sub gc :Help(Garbage collects artefacts in the backend store) | ||||||||||||||||||||||||||||||
| 306 | { | ||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
gc: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||
| 309 | 0 | _getopt($c); | |||||||||||||||||||||||||||||
| 310 | 0 | _gc($c); | |||||||||||||||||||||||||||||
| 311 | 4 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||
| 313 | ###################################################################### | ||||||||||||||||||||||||||||||
| 314 | # | ||||||||||||||||||||||||||||||
| 315 | # Implementation | ||||||||||||||||||||||||||||||
| 316 | # | ||||||||||||||||||||||||||||||
| 317 | ###################################################################### | ||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||
| 320 | sub _read_in | ||||||||||||||||||||||||||||||
| 321 | { | ||||||||||||||||||||||||||||||
| 322 | 3 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_read_in: called CC=10 SCAR=28.8
| |||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||
| 324 | 3 | my $opt = $c->options; | |||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||
| 326 | 3 | my $file = $c->{_file}; | |||||||||||||||||||||||||||||
| 327 | 3 | ▶ | my $intype = $opt->{intype} || 'json'; | ||||||||||||||||||||||||||||
|
Condition50%1/2
$opt->{'intype'} || 'json'
MC/DC0%0/1
$opt->{'intype'} || 'json'
$opt->{'intype'}
Truth table50%1/2
A
A= $opt->{'intype'}
| |||||||||||||||||||||||||||||||
| 328 | 3 | my $data; | |||||||||||||||||||||||||||||
| 329 | my $filecontent; | ||||||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||||
| 331 | 3 | local $/; | |||||||||||||||||||||||||||||
| 332 | 3 | ▶ | if (defined $opt->{data}) { | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 333 | 0 | $filecontent = $opt->{data}; | |||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||
| 335 | elsif ($file eq '-') { | ||||||||||||||||||||||||||||||
| 336 | 0 | $filecontent = <STDIN>; | |||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||
| 338 | else | ||||||||||||||||||||||||||||||
| 339 | { | ||||||||||||||||||||||||||||||
| 340 | 3 | ▶ | open (my $FH, "<", $file) or die "benchmarkanything-storage: cannot open input file $file.\n"; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 341 | 3 | $filecontent = <$FH>; | |||||||||||||||||||||||||||||
| 342 | 3 | close $FH; | |||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||
| 346 | 3 | ▶ | if (not defined $filecontent or $filecontent !~ /[^\s\t\r\n]/ms) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $filecontent and $filecontent =~ /[^\s\t\r\n]/ms
MC/DC0%0/2
defined $filecontent and $filecontent =~ /[^\s\t\r\n]/ms
defined $filecontent
$filecontent =~ /[^\s\t\r\n]/ms
Truth table33%1/3
A and B
A= defined $filecontentB= $filecontent =~ /[^\s\t\r\n]/ms
| |||||||||||||||||||||||||||||||
| 347 | 0 | die "benchmarkanything-storage: no meaningful input to read.\n"; | |||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||
| 350 | 3 | ▶ | if ($intype eq "yaml") { | ||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||
| 351 | 0 | require YAML::Any; | |||||||||||||||||||||||||||||
| 352 | 0 | $data = [YAML::Any::Load($filecontent)]; | |||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||
| 354 | elsif ($intype eq "json") { | ||||||||||||||||||||||||||||||
| 355 | 3 | require JSON; | |||||||||||||||||||||||||||||
| 356 | 3 | $data = JSON::decode_json($filecontent); | |||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||
| 358 | elsif ($intype eq "dumper") { | ||||||||||||||||||||||||||||||
| 359 | 0 | eval '$data = my '.$filecontent; | |||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||
| 361 | else | ||||||||||||||||||||||||||||||
| 362 | { | ||||||||||||||||||||||||||||||
| 363 | 0 | die "benchmarkanything-storage: unrecognized input format: $intype.\n"; | |||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||
| 365 | 3 | return $data; | |||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||
| 369 | sub _write_out | ||||||||||||||||||||||||||||||
| 370 | { | ||||||||||||||||||||||||||||||
| 371 | 1 | ▶ | my ($c, $data) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_write_out: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||
| 373 | 1 | return $c->{_balib}->_output_format($data, $c->options); | |||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||
| 376 | sub _listnames | ||||||||||||||||||||||||||||||
| 377 | { | ||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_listnames: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||
| 380 | 0 | my $result = $c->{_balib}->listnames ($c->options->{pattern}); | |||||||||||||||||||||||||||||
| 381 | 0 | _write_out($c, $result); | |||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||
| 384 | sub _listkeys | ||||||||||||||||||||||||||||||
| 385 | { | ||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_listkeys: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||
| 388 | 0 | my $result = $c->{_balib}->listkeys ($c->options->{pattern}); | |||||||||||||||||||||||||||||
| 389 | 0 | _write_out($c, $result); | |||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||
| 392 | sub _stats | ||||||||||||||||||||||||||||||
| 393 | { | ||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_stats: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||
| 396 | 0 | my $result = $c->{_balib}->stats; | |||||||||||||||||||||||||||||
| 397 | 0 | _write_out($c, $result); | |||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||
| 400 | sub _processqueue | ||||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_processqueue: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||
| 404 | 0 | $c->{_balib}->process_raw_result_queue(100); | |||||||||||||||||||||||||||||
| 405 | 0 | return; | |||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||
| 408 | sub _init_search_engine | ||||||||||||||||||||||||||||||
| 409 | { | ||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_init_search_engine: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||
| 412 | 0 | $c->{_balib}->init_search_engine($c->options->{force}); | |||||||||||||||||||||||||||||
| 413 | 0 | return; | |||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||
| 416 | sub _sync_search_engine | ||||||||||||||||||||||||||||||
| 417 | { | ||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_sync_search_engine: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | my $force = $c->options->{force} || 0; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$c->options->{'force'} || 0
MC/DC0%0/1
$c->options->{'force'} || 0
$c->options->{'force'}
Truth table0%0/2
A
A= $c->options->{'force'}
| |||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | my $startid = $c->options->{startid} || 1; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$c->options->{'startid'} || 1
MC/DC0%0/1
$c->options->{'startid'} || 1
$c->options->{'startid'}
Truth table0%0/2
A
A= $c->options->{'startid'}
| |||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | my $bulkcount = $c->options->{bulkcount} || 10_000; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$c->options->{'bulkcount'} || 10000
MC/DC0%0/1
$c->options->{'bulkcount'} || 10000
$c->options->{'bulkcount'}
Truth table0%0/2
A
A= $c->options->{'bulkcount'}
| |||||||||||||||||||||||||||||||
| 423 | 0 | $c->{_balib}->sync_search_engine($force, $startid, $bulkcount); | |||||||||||||||||||||||||||||
| 424 | 0 | return; | |||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||
| 427 | sub _gc | ||||||||||||||||||||||||||||||
| 428 | { | ||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_gc: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||
| 431 | 0 | $c->{_balib}->gc; | |||||||||||||||||||||||||||||
| 432 | 0 | return; | |||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||
| 435 | sub _search | ||||||||||||||||||||||||||||||
| 436 | { | ||||||||||||||||||||||||||||||
| 437 | 2 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_search: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||
| 439 | 2 | my $result; | |||||||||||||||||||||||||||||
| 440 | 2 | my $value_id = $c->options->{id}; | |||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||
| 442 | # special case: search --id gets a full point with all details | ||||||||||||||||||||||||||||||
| 443 | 2 | ▶ | if ($value_id) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 444 | 0 | $result = $c->{_balib}->search(undef, $value_id); | |||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||
| 446 | else | ||||||||||||||||||||||||||||||
| 447 | { | ||||||||||||||||||||||||||||||
| 448 | 2 | my $query = _read_in($c); | |||||||||||||||||||||||||||||
| 449 | 2 | $result = $c->{_balib}->search($query); | |||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||
| 451 | 1 | _write_out($c, $result); | |||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||
| 454 | sub _add | ||||||||||||||||||||||||||||||
| 455 | { | ||||||||||||||||||||||||||||||
| 456 | 1 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_add: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||
| 458 | 1 | my $data = _read_in($c); | |||||||||||||||||||||||||||||
| 459 | 1 | $c->{_balib}->add ($data); | |||||||||||||||||||||||||||||
| 460 | 0 | return; | |||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||
| 463 | sub _createdb | ||||||||||||||||||||||||||||||
| 464 | { | ||||||||||||||||||||||||||||||
| 465 | 1 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_createdb: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||
| 467 | 1 | $c->{_balib}->createdb; | |||||||||||||||||||||||||||||
| 468 | 1 | return; | |||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||
| 471 | sub _init | ||||||||||||||||||||||||||||||
| 472 | { | ||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | my ($c) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||
| 475 | 0 | my $old_verbose = $c->{_balib}{verbose}; | |||||||||||||||||||||||||||||
| 476 | 0 | $c->{_balib}{verbose} = 1; | |||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||
| 478 | 0 | $c->{_balib}->init_workdir; | |||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||
| 480 | 0 | $c->{_balib}{verbose} = $old_verbose; | |||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||
| 482 | 0 | return; | |||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||
| 485 | __END__ | ||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||
| 487 | =pod | ||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||
| 489 | =encoding UTF-8 | ||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||
| 491 | =head1 NAME | ||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||
| 493 | benchmarkanything-storage - BenchmarkAnything storage cmdline tool | ||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||
| 495 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||
| 497 | Default data format (in and out) is JSON, other formats can be | ||||||||||||||||||||||||||||||
| 498 | specified. | ||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||
| 500 | =over 4 | ||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||
| 502 | =item * Initialize BenchmarkAnything: | ||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||
| 504 | $ benchmarkanything-storage init | ||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||
| 506 | =item * OPTIONAL: Configure MySQL | ||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||
| 508 | Iff you want to use MySQL instead of the default SQLite, then edit the | ||||||||||||||||||||||||||||||
| 509 | just created C<~/.benchmarkanything/default.cfg> and in the section | ||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||
| 511 | benchmarkanything: | ||||||||||||||||||||||||||||||
| 512 | backend: local | ||||||||||||||||||||||||||||||
| 513 | storage: | ||||||||||||||||||||||||||||||
| 514 | backend: | ||||||||||||||||||||||||||||||
| 515 | sql: | ||||||||||||||||||||||||||||||
| 516 | dsn: dbi:SQLite:... | ||||||||||||||||||||||||||||||
| 517 | #dsn: DBI:mysql:database=benchmarkanything | ||||||||||||||||||||||||||||||
| 518 | #user: benchmarker | ||||||||||||||||||||||||||||||
| 519 | #password: secret | ||||||||||||||||||||||||||||||
| 520 | ... | ||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||
| 522 | comment out the I<dsn:dbi:SQLite...> line and uncomment the | ||||||||||||||||||||||||||||||
| 523 | I<dsn:DBI:mysql...> and corresponding I<user:> and I<password:> | ||||||||||||||||||||||||||||||
| 524 | lines, so it now looks like: | ||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||
| 526 | benchmarkanything: | ||||||||||||||||||||||||||||||
| 527 | backend: local | ||||||||||||||||||||||||||||||
| 528 | storage: | ||||||||||||||||||||||||||||||
| 529 | backend: | ||||||||||||||||||||||||||||||
| 530 | sql: | ||||||||||||||||||||||||||||||
| 531 | #dsn: dbi:SQLite:... | ||||||||||||||||||||||||||||||
| 532 | dsn: DBI:mysql:database=benchmarkanything | ||||||||||||||||||||||||||||||
| 533 | user: benchmarker | ||||||||||||||||||||||||||||||
| 534 | password: secret | ||||||||||||||||||||||||||||||
| 535 | ... | ||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||
| 537 | And yes, choose a better password! | ||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||
| 539 | Then initialize you MySQL like this: | ||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||
| 541 | $ sudo apt-get install mysql-server-5.6 mysql-client-5.6 | ||||||||||||||||||||||||||||||
| 542 | $ mysql -u root -p | ||||||||||||||||||||||||||||||
| 543 | mysql> create database if not exists benchmarkanything; | ||||||||||||||||||||||||||||||
| 544 | mysql> create user 'benchmarker'@'localhost' identified by 'secret'; | ||||||||||||||||||||||||||||||
| 545 | mysql> grant all privileges on benchmarkanything.* to 'benchmarker'@'localhost'; | ||||||||||||||||||||||||||||||
| 546 | mysql> flush privileges; | ||||||||||||||||||||||||||||||
| 547 | mysql> quit; | ||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||
| 549 | =item * Create BenchmarkAnything storage database: | ||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||
| 551 | $ benchmarkanything-storage createdb | ||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||
| 553 | This will ask if you are sure before it creates the actual db with | ||||||||||||||||||||||||||||||
| 554 | tables. | ||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||
| 556 | =item * Add data to backend storage: | ||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||
| 558 | $ benchmarkanything-storage add data.json | ||||||||||||||||||||||||||||||
| 559 | $ benchmarkanything-storage add -i yaml data.yaml | ||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||
| 561 | =item * Query backend storage for data: | ||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||
| 563 | $ echo 'json_search_query' | benchmarkanything-storage search - | ||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||
| 565 | =back | ||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||
| 567 | =head2 Input formats | ||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||
| 569 | The following B<input formats> are allowed, with their according | ||||||||||||||||||||||||||||||
| 570 | modules used to convert the input into a data structure: | ||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||
| 572 | yaml - YAML::Any (default) | ||||||||||||||||||||||||||||||
| 573 | json - JSON | ||||||||||||||||||||||||||||||
| 574 | dumper - Data::Dumper (including the leading $VAR1 variable assignment) | ||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||
| 576 | =head2 Output formats | ||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||
| 578 | The following B<output formats> are allowed: | ||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||
| 580 | yaml - YAML::Any | ||||||||||||||||||||||||||||||
| 581 | json - JSON (default) | ||||||||||||||||||||||||||||||
| 582 | xml - XML::Simple | ||||||||||||||||||||||||||||||
| 583 | ini - Config::INI::Serializer | ||||||||||||||||||||||||||||||
| 584 | dumper - Data::Dumper (including the leading $VAR1 variable assignment) | ||||||||||||||||||||||||||||||
| 585 | flat - pragmatic flat output for typical unixish cmdline usage | ||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||
| 587 | See L<BenchmarkAnything::Storage::Frontend::Lib/Output formats> for | ||||||||||||||||||||||||||||||
| 588 | more details, especially about the I<flat> output format. | ||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||
| 590 | =head2 _read_in | ||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||
| 592 | This function reads in a data structure. The meaning of the data | ||||||||||||||||||||||||||||||
| 593 | depends on the sub command: for C<search> it is a search query, for | ||||||||||||||||||||||||||||||
| 594 | C<add> it is an array of BenchmarkAnything data points. | ||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||
| 596 | =head2 _write_out | ||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||
| 598 | This function writes a data structure in requested output format. | ||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||
| 600 | =head1 ABOUT | ||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||
| 602 | Cmdline tool to handle BenchmarkAnything data, see | ||||||||||||||||||||||||||||||
| 603 | L<http://benchmarkanything.org|http://benchmarkanything.org> | ||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||
| 605 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||
| 607 | For more information about the BenchmarkAnything schema, see | ||||||||||||||||||||||||||||||
| 608 | L<http://www.benchmarkanything.org/|http://www.benchmarkanything.org/>. | ||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||
| 610 | =head1 AUTHOR | ||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||
| 612 | Steffen Schwigon <ss5@renormalist.net> | ||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||
| 614 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||
| 616 | This software is copyright (c) 2017 by Steffen Schwigon. | ||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||
| 618 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||
| 619 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||
| 621 | =cut | ||||||||||||||||||||||||||||||