1body common control 2{ 3 bundlesequence => { "benchmark" }; 4} 5 6bundle agent benchmark 7{ 8 vars: 9 # Determines how many times each example is run 10 "n" int => "10"; 11 12 # Range: 1, 2, 3, ..., n 13 "i" slist => { expandrange("[1-$(n)]", "1") }; 14 15 methods: 16 "accumulated" 17 usebundle => accumulated_bench("$(i)"); 18 "ago" 19 usebundle => ago_bench("$(i)"); 20 "and" 21 usebundle => and_bench("$(i)"); 22 "basename" 23 usebundle => basename_bench("$(i)"); 24 "bundlesmatching" 25 usebundle => bundlesmatching_bench("$(i)"); 26 "bundlestate" 27 usebundle => bundlestate_bench("$(i)"); 28 "callstack_callers" 29 usebundle => callstack_callers_bench("$(i)"); 30 "callstack_promisers" 31 usebundle => callstack_promisers_bench("$(i)"); 32 "canonify" 33 usebundle => canonify_bench("$(i)"); 34 "canonifyuniquely" 35 usebundle => canonifyuniquely_bench("$(i)"); 36 "cf_version_after" 37 usebundle => cf_version_after_bench("$(i)"); 38 "cf_version_at" 39 usebundle => cf_version_at_bench("$(i)"); 40 "cf_version_before" 41 usebundle => cf_version_before_bench("$(i)"); 42 "cf_version_between" 43 usebundle => cf_version_between_bench("$(i)"); 44 "cf_version_maximum" 45 usebundle => cf_version_maximum_bench("$(i)"); 46 "cf_version_minimum" 47 usebundle => cf_version_minimum_bench("$(i)"); 48 "classesmatching" 49 usebundle => classesmatching_bench("$(i)"); 50 "classify" 51 usebundle => classify_bench("$(i)"); 52 "classmatch" 53 usebundle => classmatch_bench("$(i)"); 54 "concat" 55 usebundle => concat_bench("$(i)"); 56 "countclassesmatching" 57 usebundle => countclassesmatching_bench("$(i)"); 58 "data_expand" 59 usebundle => data_expand_bench("$(i)"); 60 "data_regextract" 61 usebundle => data_regextract_bench("$(i)"); 62 "difference" 63 usebundle => difference_bench("$(i)"); 64 "dirname" 65 usebundle => dirname_bench("$(i)"); 66 "escape" 67 usebundle => escape_bench("$(i)"); 68 "eval" 69 usebundle => eval_bench("$(i)"); 70 "every" 71 usebundle => every_bench("$(i)"); 72 "expandrange" 73 usebundle => expandrange_bench("$(i)"); 74 "filter" 75 usebundle => filter_bench("$(i)"); 76 "format" 77 usebundle => format_bench("$(i)"); 78 "getclassmetatags" 79 usebundle => getclassmetatags_bench("$(i)"); 80 "getindices" 81 usebundle => getindices_bench("$(i)"); 82 "getvalues" 83 usebundle => getvalues_bench("$(i)"); 84 "getvariablemetatags" 85 usebundle => getvariablemetatags_bench("$(i)"); 86 "grep" 87 usebundle => grep_bench("$(i)"); 88 "hash" 89 usebundle => hash_bench("$(i)"); 90 "hash_to_int" 91 usebundle => hash_to_int_bench("$(i)"); 92 "ifelse" 93 usebundle => ifelse_bench("$(i)"); 94 "intersection" 95 usebundle => intersection_bench("$(i)"); 96 "isgreaterthan" 97 usebundle => isgreaterthan_bench("$(i)"); 98 "islessthan" 99 usebundle => islessthan_bench("$(i)"); 100 "isvariable" 101 usebundle => isvariable_bench("$(i)"); 102 "join" 103 usebundle => join_bench("$(i)"); 104 "laterthan" 105 usebundle => laterthan_bench("$(i)"); 106 "length" 107 usebundle => length_bench("$(i)"); 108 "maparray" 109 usebundle => maparray_bench("$(i)"); 110 "mapdata" 111 usebundle => mapdata_bench("$(i)"); 112 "maplist" 113 usebundle => maplist_bench("$(i)"); 114 "max" 115 usebundle => max_bench("$(i)"); 116 "mean" 117 usebundle => mean_bench("$(i)"); 118 "mergedata" 119 usebundle => mergedata_bench("$(i)"); 120 "min" 121 usebundle => min_bench("$(i)"); 122 "none" 123 usebundle => none_bench("$(i)"); 124 "not" 125 usebundle => not_bench("$(i)"); 126 "now" 127 usebundle => now_bench("$(i)"); 128 "nth" 129 usebundle => nth_bench("$(i)"); 130 "on" 131 usebundle => on_bench("$(i)"); 132 "or" 133 usebundle => or_bench("$(i)"); 134 "parseintarray" 135 usebundle => parseintarray_bench("$(i)"); 136 "parsejson" 137 usebundle => parsejson_bench("$(i)"); 138 "parserealarray" 139 usebundle => parserealarray_bench("$(i)"); 140 "parsestringarray" 141 usebundle => parsestringarray_bench("$(i)"); 142 "parsestringarrayidx" 143 usebundle => parsestringarrayidx_bench("$(i)"); 144 "product" 145 usebundle => product_bench("$(i)"); 146 "random" 147 usebundle => randomint_bench("$(i)"); 148 "regarray" 149 usebundle => regarray_bench("$(i)"); 150 "regcmp" 151 usebundle => regcmp_bench("$(i)"); 152 "regex_replace" 153 usebundle => regex_replace_bench("$(i)"); 154 "regextract" 155 usebundle => regextract_bench("$(i)"); 156 "reglist" 157 usebundle => reglist_bench("$(i)"); 158 "reverse" 159 usebundle => reverse_bench("$(i)"); 160 "shuffle" 161 usebundle => shuffle_bench("$(i)"); 162 "some" 163 usebundle => some_bench("$(i)"); 164 "sort" 165 usebundle => sort_bench("$(i)"); 166 "splitstring" 167 usebundle => splitstring_bench("$(i)"); 168 "storejson" 169 usebundle => storejson_bench("$(i)"); 170 "strcmp" 171 usebundle => strcmp_bench("$(i)"); 172 "strftime" 173 usebundle => strftime_bench("$(i)"); 174 "string_downcase" 175 usebundle => string_downcase_bench("$(i)"); 176 "string_head" 177 usebundle => string_head_bench("$(i)"); 178 "string_length" 179 usebundle => string_length_bench("$(i)"); 180 "string_mustache" 181 usebundle => string_mustache_bench("$(i)"); 182 "string_replace" 183 usebundle => string_replace_bench("$(i)"); 184 "string_reverse" 185 usebundle => string_reverse_bench("$(i)"); 186 "string_split" 187 usebundle => string_split_bench("$(i)"); 188 "string_tail" 189 usebundle => string_tail_bench("$(i)"); 190 "string_upcase" 191 usebundle => string_upcase_bench("$(i)"); 192 "sublist" 193 usebundle => sublist_bench("$(i)"); 194 "sum" 195 usebundle => sum_bench("$(i)"); 196 "translatepath" 197 usebundle => translatepath_bench("$(i)"); 198 "unique" 199 usebundle => unique_bench("$(i)"); 200 "validdata" 201 usebundle => validdata_bench("$(i)"); 202 "validjson" 203 usebundle => validjson_bench("$(i)"); 204 "variablesmatching" 205 usebundle => variablesmatching_bench("$(i)"); 206 "variablesmatching_as_data" 207 usebundle => variablesmatching_as_data_bench("$(i)"); 208 "variance" 209 usebundle => variance_bench("$(i)"); 210 "done" 211 usebundle => print_benchmark_done_msg(); 212} 213 214bundle agent accumulated_bench(i) 215{ 216 vars: 217 "test" 218 int => accumulated("$(i)", "$(i)", "$(i)", "$(i)", "$(i)", "$(i)"); 219 reports: 220 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 221} 222 223bundle agent ago_bench(i) 224{ 225 vars: 226 "test" 227 int => ago("$(i)", "$(i)", "$(i)", "$(i)", "$(i)", "$(i)"); 228 reports: 229 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 230} 231 232bundle agent and_bench(i) 233{ 234 classes: 235 "test_1" 236 expression => and("any_$(i)", "any_$(i)"); 237 "test_2" 238 expression => and("any_$(i)", "!any_$(i)"); 239 "test_3" 240 expression => and("!any_$(i)", "any_$(i)"); 241 "test_4" 242 expression => and("!any_$(i)", "!any_$(i)"); 243 reports: 244 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 245} 246 247bundle agent basename_bench(i) 248{ 249 vars: 250 "test_1" 251 string => basename("/tmp/test_$(i).txt"); 252 "test_2" 253 string => basename("/tmp/test_$(i).txt", ".txt"); 254 reports: 255 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 256} 257 258bundle agent bundlesmatching_bench(i) 259{ 260 vars: 261 "test" 262 slist => bundlesmatching(".*"); 263 reports: 264 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 265} 266 267bundle agent bundlestate_bench(i) 268{ 269 vars: 270 "test" 271 data => bundlestate("benchmark"); 272 reports: 273 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 274} 275 276bundle agent callstack_callers_bench(i) 277{ 278 vars: 279 "test" 280 data => callstack_callers(); 281 reports: 282 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 283} 284 285bundle agent callstack_promisers_bench(i) 286{ 287 vars: 288 "test" 289 slist => callstack_promisers(); 290 reports: 291 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 292} 293 294bundle agent canonify_bench(i) 295{ 296 vars: 297 "test" 298 string => canonify("/home/root/test-$(i).txt"); 299 reports: 300 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 301} 302 303bundle agent canonifyuniquely_bench(i) 304{ 305 vars: 306 "test" 307 string => canonifyuniquely("/home/root/test-$(i).txt"); 308 reports: 309 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 310} 311 312bundle agent cf_version_after_bench(i) 313{ 314 classes: 315 "test" 316 expression => cf_version_after("3.$(i)"); 317 reports: 318 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 319} 320 321bundle agent cf_version_at_bench(i) 322{ 323 classes: 324 "test" 325 expression => cf_version_at("3.$(i)"); 326 reports: 327 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 328} 329 330bundle agent cf_version_before_bench(i) 331{ 332 classes: 333 "test" 334 expression => cf_version_before("3.$(i)"); 335 reports: 336 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 337} 338 339bundle agent cf_version_between_bench(i) 340{ 341 classes: 342 "test" 343 expression => cf_version_between("3.$(i)", "4"); 344 reports: 345 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 346} 347 348bundle agent cf_version_maximum_bench(i) 349{ 350 classes: 351 "test" 352 expression => cf_version_maximum("3.$(i)"); 353 reports: 354 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 355} 356 357bundle agent cf_version_minimum_bench(i) 358{ 359 classes: 360 "test" 361 expression => cf_version_minimum("3.$(i)"); 362 reports: 363 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 364} 365 366bundle agent classesmatching_bench(i) 367{ 368 vars: 369 "test" 370 slist => classesmatching(".*$(i).*"); 371 reports: 372 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 373} 374 375bundle agent classify_bench(i) 376{ 377 classes: 378 "test" 379 expression => classify("/home/root/test-$(i).txt"); 380 reports: 381 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 382} 383 384bundle agent classmatch_bench(i) 385{ 386 classes: 387 "test" 388 expression => classmatch(".*$(i).*", "hardclass"); 389 reports: 390 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 391} 392 393bundle agent concat_bench(i) 394{ 395 vars: 396 "test" 397 string => concat("file", "_$(i)", ".txt"); 398 reports: 399 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 400} 401 402bundle agent countclassesmatching_bench(i) 403{ 404 vars: 405 "test" 406 int => countclassesmatching(".*$(i).*"); 407 reports: 408 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 409} 410 411bundle agent data_expand_bench(i) 412{ 413 vars: 414 "json" 415 data => '{ "i": $(i) }'; 416 "expanded" 417 data => data_expand("json"); 418 reports: 419 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 420} 421 422bundle agent data_regextract_bench(i) 423{ 424 vars: 425 "parsed" 426 data => data_regextract("^(?<name1>...)(...)(..)-(?<name2>...)-(..).*", 427 "abcdef12-345-$(i)andsoon"); 428 reports: 429 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 430} 431 432bundle agent difference_bench(i) 433{ 434 vars: 435 "a" 436 slist => { "a", "b", "c", "d", "e", "f", "$(i)" }; 437 "b" 438 slist => { "a", "c", "e", "g", "i", "k" }; 439 "diff" 440 slist => difference(a, b); 441 reports: 442 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 443} 444 445bundle agent dirname_bench(i) 446{ 447 vars: 448 "dir" 449 string => dirname("/dir/dir_$(i)/file"); 450 reports: 451 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 452} 453 454bundle agent escape_bench(i) 455{ 456 vars: 457 "node" 458 string => format("%d", eval("($(i) - 1) % 256")); 459 "ip" 460 string => "192.168.1.$(node)"; 461 "escaped" 462 string => escape("$(ip)"); 463 reports: 464 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 465} 466 467bundle agent eval_bench(i) 468{ 469 vars: 470 "hyp" 471 string => eval("sqrt( ( ($(i) * $(i)) + ($(i) * $(i)) ) )", "math", "infix"); 472 "same" 473 string => eval("$(i) == sqrt($(i) * $(i))", "class", "infix"); 474 reports: 475 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 476} 477 478bundle agent every_bench(i) 479{ 480 vars: 481 "test" 482 slist => { "/var/cfengine/bin/cf-agent", "/var/cfengine/bin/cf-execd", "/var/cfengine/bin/rpmvercmp", "/var/cfengine/bin/cf-$(i)" }; 483 classes: 484 "yes" 485 expression => every("/var/cfengine/bin/.*", test); 486 "no" 487 expression => every("/var/cfengine/bin/cf-.*", test); 488 reports: 489 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 490} 491 492bundle agent expandrange_bench(i) 493{ 494 vars: 495 "range" 496 slist=> { expandrange("[0-$(i)]", "1") }; 497 reports: 498 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 499} 500 501bundle agent filter_bench(i) 502{ 503 vars: 504 "natural" 505 slist => { expandrange("[0-$(i)]", "1") }; 506 "odd" 507 slist => filter("[0-9]*[02468]", natural, "true", "false", "inf"); 508 reports: 509 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 510} 511 512bundle agent format_bench(i) 513{ 514 vars: 515 "formatted" 516 string => format("num: %s", "$(i)"); 517 reports: 518 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 519} 520 521bundle agent getclassmetatags_bench(i) 522{ 523 classes: 524 "myclass" 525 expression => "any", 526 meta => { "tag_$(i)" }; 527 vars: 528 "metatags" 529 slist => getclassmetatags("myclass"); 530 reports: 531 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 532} 533 534bundle agent getindices_bench(i) 535{ 536 vars: 537 "test[i$(i)]" 538 string => "v$(i)"; 539 "indices" 540 slist => getindices(test); 541 reports: 542 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 543} 544 545bundle agent getvalues_bench(i) 546{ 547 vars: 548 "test[i$(i)]" 549 string => "v$(i)"; 550 "values" 551 slist => getvalues(test); 552 reports: 553 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 554} 555 556bundle agent getvariablemetatags_bench(i) 557{ 558 vars: 559 "myvar" 560 string => "hello", 561 meta => { "tag_$(i)" }; 562 "metatags" 563 slist => getvariablemetatags(myvar); 564 reports: 565 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 566} 567 568bundle agent grep_bench(i) 569{ 570 vars: 571 "mylist" 572 slist => { "One", "Two", "Three", "Four", "Five", "T$(i)" }; 573 "tlist" 574 slist => grep("T.*", mylist); 575 reports: 576 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 577} 578 579bundle agent hash_bench(i) 580{ 581 vars: 582 "md5" string => hash("Cfengine $(i) is not cryptic","md5"); 583 "sha256" string => hash("Cfengine $(i) is not cryptic","sha256"); 584 "sha384" string => hash("Cfengine $(i) is not cryptic","sha384"); 585 "sha512" string => hash("Cfengine $(i) is not cryptic","sha512"); 586 reports: 587 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 588} 589 590bundle agent hash_to_int_bench(i) 591{ 592 vars: 593 "a" int => hash_to_int(0, "$(i)", "hello"); 594 "b" int => hash_to_int(0, "$(i)", "world"); 595 "c" int => hash_to_int(0, "$(i)", "$(sys.key_digest)"); 596 "d" int => hash_to_int(0, "$(i)", "$(sys.policy_hub)"); 597 reports: 598 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 599} 600 601bundle agent ifelse_bench(i) 602{ 603 vars: 604 "outcome" 605 string => ifelse(regcmp("[0-9]*[02468]", "$(i)"), "is odd", 606 regcmp("[0-9]", "$(i)"), "is less than 10", 607 "is even"); 608 reports: 609 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 610} 611 612bundle agent intersection_bench(i) 613{ 614 vars: 615 "a" 616 slist => { "a", "b", "c", "d", "e", "f", "$(i)" }; 617 "b" 618 slist => { "a", "c", "e", "g", "i", "k", "$(i)" }; 619 "inter" 620 slist => intersection(a, b); 621 reports: 622 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 623} 624 625bundle agent isgreaterthan_bench(i) 626{ 627 classes: 628 "indeed" 629 expression => isgreaterthan("5", "$(i)"); 630 reports: 631 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 632} 633 634bundle agent islessthan_bench(i) 635{ 636 classes: 637 "indeed" 638 expression => islessthan("5", "$(i)"); 639 reports: 640 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 641} 642 643bundle agent isvariable_bench(i) 644{ 645 vars: 646 "defined_$(i)" 647 string => "this var is defined"; 648 classes: 649 "test_1" 650 expression => isvariable("defined_$(i)"); 651 "test_2" 652 expression => isvariable("undefined_$(i)"); 653 reports: 654 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 655} 656 657bundle agent join_bench(i) 658{ 659 vars: 660 "list" 661 slist => { "a", "b", "c", "d", "e", "$(i)" }; 662 "joined_list" 663 string => join(", ", list); 664 "dat" 665 data => '[ "a", "b", "c", "d", "e", "$(i)" ]'; 666 "joined_data" 667 string => join("->", dat); 668 reports: 669 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 670} 671 672bundle agent laterthan_bench(i) 673{ 674 classes: 675 "test" 676 expression => laterthan("$(i)", "$(i)", "$(i)", "$(i)", "$(i)", "$(i)"); 677 reports: 678 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 679} 680 681bundle agent length_bench(i) 682{ 683 vars: 684 "list" 685 slist => { expandrange("[0-$(i)]", "1") }; 686 "len" 687 int => length(list); 688 reports: 689 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 690} 691 692bundle agent maparray_bench(i) 693{ 694 vars: 695 "arr[0]" 696 string => "a"; 697 "arr[1]" 698 string => "b"; 699 "arr[2]" 700 string => "c"; 701 "arr[3]" 702 string => "d"; 703 "arr[4]" 704 string => "e"; 705 "arr[5]" 706 string => "$(i)"; 707 "mapped" 708 slist => maparray("key=$(this.k), val=$(this.v)", arr); 709 reports: 710 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 711} 712 713bundle agent mapdata_bench(i) 714{ 715 vars: 716 "dat" 717 data => '{ "name": "alice", "age": $(i) }'; 718 "map_json" 719 data => mapdata("json", '{ "key": "$(this.k)", "value": "$(this.v)" }', dat); 720 reports: 721 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 722} 723 724bundle agent maplist_bench(i) 725{ 726 vars: 727 "list" 728 slist => { "a", "b", "c", "d", "e", "$(i)" }; 729 "mapped" 730 slist => maplist("Element: $(this)", list); 731 reports: 732 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 733} 734 735bundle agent max_bench(i) 736{ 737 vars: 738 "alpha" 739 slist => { "a", "c", "b", "d", "f", "$(i)" }; 740 "numer" 741 ilist => { 1, 3, 2, 4, 6, "$(i)" }; 742 "alpha_max" 743 string => max(alpha, "lex"); 744 "numer_max" 745 string => max(numer, "int"); 746 reports: 747 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 748} 749 750bundle agent mean_bench(i) 751{ 752 vars: 753 "list" 754 slist => { "a", "1", "b", "2", "f", "$(i)" }; 755 "mean" 756 real => mean(list); 757 reports: 758 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 759} 760 761bundle agent mergedata_bench(i) 762{ 763 vars: 764 "d1" 765 data => '{ "name": "alice" }'; 766 "d2" 767 data => '{ "age": $(i) }'; 768 "data" 769 data => mergedata(d1, d2); 770 reports: 771 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 772} 773 774bundle agent min_bench(i) 775{ 776 vars: 777 "alpha" 778 slist => { "a", "c", "b", "d", "f", "$(i)" }; 779 "numer" 780 ilist => { 1, 3, 2, 4, 6, "$(i)" }; 781 "alpha_min" 782 string => min(alpha, "lex"); 783 "numer_min" 784 string => min(numer, "int"); 785 reports: 786 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 787} 788 789bundle agent none_bench(i) 790{ 791 vars: 792 "list" 793 slist => { "a", "b", "c", "$(i)" }; 794 classes: 795 "test_2" 796 expression => none("[0-9]", list); 797 reports: 798 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 799} 800 801bundle agent not_bench(i) 802{ 803 classes: 804 "myclass_$(i)" 805 expression => "any"; 806 "yes" 807 expression => not("!myclass_$(i)"); 808 "no" 809 expression => not("myclass_$(i)"); 810 reports: 811 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 812} 813 814bundle agent now_bench(i) 815{ 816 vars: 817 "epoch" 818 int => now(); 819 reports: 820 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 821} 822 823bundle agent nth_bench(i) 824{ 825 vars: 826 "list" 827 slist => { "a", "b", "c", "d", "e", "$(i)" }; 828 "first" 829 string => nth(list, "0"); 830 "second" 831 string => nth(list, "1"); 832 "third" 833 string => nth(list, "2"); 834 "forth" 835 string => nth(list, "3"); 836 "fifth" 837 string => nth(list, "4"); 838 "sixth" 839 string => nth(list, "5"); 840 reports: 841 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 842} 843 844bundle agent on_bench(i) 845{ 846 vars: 847 "epoch" 848 int => on("$(i)", "$(i)", "$(i)", "$(i)", "$(i)", "$(i)"); 849 reports: 850 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 851} 852 853bundle agent or_bench(i) 854{ 855 classes: 856 "myclass_$(i)" 857 expression => "any"; 858 "test_1" 859 expression => or("myclass_$(i)", "myclass_$(i)"); 860 "test_2" 861 expression => or("myclass_$(i)", "!myclass_$(i)"); 862 "test_3" 863 expression => or("!myclass_$(i)", "myclass_$(i)"); 864 "test_3" 865 expression => or("!myclass_$(i)", "!myclass_$(i)"); 866 reports: 867 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 868} 869 870bundle agent parseintarray_bench(i) 871{ 872 vars: 873 # Define data inline for convenience 874 "table" 875 string => 876 "1:2 877 3:4 878 $(i):6"; 879 "dim" 880 int => parseintarray("items", "$(table)", "\s*#[^\n]*", ":", "1000", "200000"); 881 reports: 882 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 883} 884 885bundle agent parsejson_bench(i) 886{ 887 vars: 888 "json" 889 string => '{ "name": "alice", "age": $(i) }'; 890 "data" 891 data => parsejson("$(json)"); 892 reports: 893 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 894} 895 896bundle agent parserealarray_bench(i) 897{ 898 vars: 899 "table" 900 string => 901 "1.1:2.2 902 3.3:4.4 903 $(i).5:6.6"; 904 "dim" 905 int => parserealarray("items", "$(table)", "\s*#[^\n]*", ":", "1000", "200000"); 906 reports: 907 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 908} 909 910bundle agent parsestringarray_bench(i) 911{ 912 vars: 913 "table" 914 string => 915 "a:b 916 c:d 917 $(i):f"; 918 "dim" 919 int => parsestringarray("items", "$(table)", "\s*#[^\n]*", ":", "1000", "200000"); 920 reports: 921 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 922} 923 924bundle agent parsestringarrayidx_bench(i) 925{ 926 vars: 927 "table" 928 string => 929 "one: a 930 two: b 931 $(i): c"; 932 "dim" 933 int => parsestringarrayidx("items", "$(table)", "\s*#[^\n]*", ":", "1000", "200000"); 934 reports: 935 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 936} 937 938bundle agent product_bench(i) 939{ 940 vars: 941 "series" 942 rlist => { "1.1", "1.2", "2.3", "3.$(i)" }; 943 "prod" 944 real => product(series); 945 reports: 946 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 947} 948 949bundle agent randomint_bench(i) 950{ 951 vars: 952 "rand" 953 int => randomint("0", "$(i)"); 954 reports: 955 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 956} 957 958bundle agent regarray_bench(i) 959{ 960 vars: 961 "array[0]" 962 string => "a1"; 963 "array[1]" 964 string => "a2"; 965 "array[2]" 966 string => "b$(i)"; 967 classes: 968 "yes" 969 expression => regarray(array, "[ab][123]"); 970 "no" 971 expression => regarray(array, "[cd][456]"); 972 reports: 973 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 974} 975 976bundle agent regcmp_bench(i) 977{ 978 classes: 979 "odd" 980 expression => regcmp("[0-9]*[02468]", "$(i)"); 981 "par" 982 expression => regcmp("[0-9]*[13579]", "$(i)"); 983 reports: 984 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 985} 986 987bundle agent regex_replace_bench(i) 988{ 989 vars: 990 "str" 991 string => regex_replace("$(i)", "[0-9]*[02468]", "odd", "i"); 992 reports: 993 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 994} 995 996bundle agent regextract_bench(i) 997{ 998 classes: 999 "ok" 1000 expression => regextract("abc([0-9]+)def", "abc$(i)def", "arr"); 1001 reports: 1002 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1003} 1004 1005bundle agent reglist_bench(i) 1006{ 1007 vars: 1008 "test" 1009 slist => { "a", "$(i)", "c" }; 1010 classes: 1011 "yes" 1012 expression => reglist("@(test)", "[0-9]*[02468]"); 1013 reports: 1014 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1015} 1016 1017bundle agent reverse_bench(i) 1018{ 1019 vars: 1020 "test" 1021 slist => { "a", "b", "c", "1", "2", "$(i)" }; 1022 "reversed" 1023 slist => reverse(test); 1024 reports: 1025 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1026} 1027 1028bundle agent shuffle_bench(i) 1029{ 1030 vars: 1031 "test" 1032 slist => { "a", "b", "c", "1", "2", "3" }; 1033 "shuffled" 1034 slist => shuffle(test, "seed_$(i)"); 1035 reports: 1036 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1037} 1038 1039bundle agent some_bench(i) 1040{ 1041 vars: 1042 "test" 1043 slist => { "a", "b", "c", "1", "$(i)", "3" }; 1044 classes: 1045 "yes" 1046 expression => some("[0-9]*[02468]", test); 1047 reports: 1048 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1049} 1050 1051bundle agent sort_bench(i) 1052{ 1053 vars: 1054 "test" 1055 slist => { "1", "2", "3", "4", "5", "$(i)" }; 1056 "shuffled" 1057 slist => shuffle(test, "seed_$(i)"); 1058 "lex" 1059 slist => sort(shuffled, "lex"); 1060 "int" 1061 slist => sort(shuffled, "int"); 1062 reports: 1063 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1064} 1065 1066bundle agent splitstring_bench(i) 1067{ 1068 vars: 1069 "test" 1070 string => "1.5;2.3;$(i).0"; 1071 "split" 1072 slist => splitstring("$(test)", ";", "inf"); 1073 reports: 1074 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1075} 1076 1077bundle agent storejson_bench(i) 1078{ 1079 vars: 1080 "dat" 1081 data => '{ "name": "alice", "age": $(i) }'; 1082 "json" 1083 string => storejson(dat); 1084 reports: 1085 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1086} 1087 1088bundle agent strcmp_bench(i) 1089{ 1090 classes: 1091 "same" 1092 expression => strcmp("test$(i)", "test$(i)"); 1093 "diff" 1094 expression => strcmp("$(i)test", "test$(i)"); 1095 reports: 1096 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1097} 1098 1099bundle agent strftime_bench(i) 1100{ 1101 vars: 1102 "at_time" 1103 string => strftime("localtime", "%Y-%m-%d %T", "$(i)"); 1104 "gmt_at_time" 1105 string => strftime("gmtime", "%Y-%m-%d %T", "$(i)"); 1106 reports: 1107 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1108} 1109 1110bundle agent string_downcase_bench(i) 1111{ 1112 vars: 1113 "downcase" 1114 string => string_downcase("AbC dEf_$(i)"); 1115 reports: 1116 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1117} 1118 1119bundle agent string_head_bench(i) 1120{ 1121 vars: 1122 "str" 1123 string => "a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, 1, 2, 3, 4, 5, 6, 7, 8, 9"; 1124 "head" 1125 string => string_head("$(str)", "$(i)"); 1126 reports: 1127 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1128} 1129 1130bundle agent string_length_bench(i) 1131{ 1132 vars: 1133 "len" 1134 int => string_length("Hello world $(i)!"); 1135 reports: 1136 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1137} 1138 1139bundle agent string_mustache_bench(i) 1140{ 1141 vars: 1142 "deserts" 1143 data => parsejson('{"deserts":{"Africa":"Sahara","Asia":"Gobi"}}'); 1144 "data" 1145 string => string_mustache("from container $(i): deserts = {{%deserts}}from container: {{#deserts}}The desert {{.}} is in {{@}}. {{/deserts}}", deserts); 1146 reports: 1147 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1148} 1149 1150bundle agent string_replace_bench(i) 1151{ 1152 vars: 1153 "str" 1154 string => string_replace("This is a string $(i)", "string", "thing"); 1155 reports: 1156 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1157} 1158 1159bundle agent string_reverse_bench(i) 1160{ 1161 vars: 1162 "str" 1163 string => string_reverse("abcdefghijklmnopqrstuvwxyz$(i)"); 1164 reports: 1165 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1166} 1167 1168bundle agent string_split_bench(i) 1169{ 1170 vars: 1171 "split" 1172 slist => string_split("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z", ",", "$(i)"); 1173 reports: 1174 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1175} 1176 1177bundle agent string_tail_bench(i) 1178{ 1179 vars: 1180 "tail" 1181 string => string_tail("a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z", "$(i)"); 1182 reports: 1183 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1184} 1185 1186bundle agent string_upcase_bench(i) 1187{ 1188 vars: 1189 "upcase" 1190 string => string_upcase("AbC dEf_$(i)"); 1191 reports: 1192 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1193} 1194 1195bundle agent sublist_bench(i) 1196{ 1197 vars: 1198 "list" 1199 slist => { "a", "b", "c", "d", "e", "f", "g", 1200 "h", "i", "j", "k", "l", "m", "n", 1201 "o", "p", "q", "r", "s", "t", "u", 1202 "v", "x", "y", "z" }; 1203 "sub_head" 1204 slist => sublist(list, "head", "$(i)"); 1205 "sub_tail" 1206 slist => sublist(list, "tail", "$(i)"); 1207 reports: 1208 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1209} 1210 1211bundle agent sum_bench(i) 1212{ 1213 vars: 1214 "nums" 1215 ilist => { "1", "2", "3", "4", "5", "$(i)" }; 1216 "num_sum" 1217 real => sum(nums); 1218 reports: 1219 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1220} 1221 1222bundle agent translatepath_bench(i) 1223{ 1224 vars: 1225 "path" 1226 string => translatepath("/a/b/c/file_$(i).txt"); 1227 reports: 1228 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1229} 1230 1231bundle agent unique_bench(i) 1232{ 1233 vars: 1234 "uni" 1235 slist => { "one", "two", "three", 1236 "1", "2", "3", 1237 "one", "$(i)", "two" }; 1238 reports: 1239 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1240} 1241 1242bundle agent validdata_bench(i) 1243{ 1244 classes: 1245 "is_valid" 1246 expression => validdata('{ "name": "alice", "age": $(i) }', "JSON"); 1247 "not_valid" 1248 expression => validdata('{ "name": "alice", "age": $(i) ]', "JSON"); 1249 reports: 1250 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1251} 1252 1253bundle agent validjson_bench(i) 1254{ 1255 classes: 1256 "is_valid" 1257 expression => validjson('{ "name": "alice", "age": $(i) }'); 1258 "not_valid" 1259 expression => validjson('{ "name": "alice", "age": $(i) ]'); 1260 reports: 1261 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1262} 1263 1264bundle agent variablesmatching_bench(i) 1265{ 1266 vars: 1267 "matches" 1268 slist => variablesmatching(".*$(i).*", "source=agent"); 1269 reports: 1270 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1271} 1272 1273bundle agent variablesmatching_as_data_bench(i) 1274{ 1275 vars: 1276 "matches" 1277 data => variablesmatching_as_data(".*$(i).*", "source=agent"); 1278 reports: 1279 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1280} 1281 1282bundle agent variance_bench(i) 1283{ 1284 vars: 1285 "nums" 1286 ilist => { "1", "2", "3", "$(i) " }; 1287 "vari" 1288 real => variance(nums); 1289 reports: 1290 "Benching '$(this.bundle)' ($(i)/$(benchmark.n)) ..."; 1291} 1292 1293bundle agent print_benchmark_done_msg() 1294{ 1295 reports: 1296 "********** BENCHMARK DONE **********"; 1297} 1298