pike.git / lib / modules / Tools.pmod / Standalone.pmod / benchmark.pike

version» Context lines:

pike.git/lib/modules/Tools.pmod/Standalone.pmod/benchmark.pike:1:      #pike __REAL_VERSION__   constant description = "Runs some built in Pike benchmarks.";   constant help = #"   Benchmarks Pike with %d built in benchmark tests.   Arguments:      -h, --help    Shows this help text.    + -l, --list +  Shows a list of available tests. +    -s<number>, --max-seconds=<number>    Runs a test at most <number> of seconds, rounded up to the closest    complete test. Defaults to 3.      -t<glob>[,<glob>...], --tests=<glob>[,<glob>...]    Only run the specified tests.      --json, -j    Output result as JSON instead of human readable text    - --compare, -c + --compare=<file>, -c <file>    Read a result previously created by saving the output of --json and    print relative results   ";         string dot( string a, int width, bool al, bool odd )   {    string pre="",post="";    int wanted = (width-strlen(a));    string pad = " ."*(wanted/2+1);
pike.git/lib/modules/Tools.pmod/Standalone.pmod/benchmark.pike:54:    mapping(string:Tools.Shoot.Test) tests= Tools.Shoot.tests();    int seconds_per_test = 3;    array(string) test_globs = ({"*"});    bool json;    mapping comparison;       foreach(Getopt.find_all_options(args, ({    ({ "help", Getopt.NO_ARG, "-h,--help"/"," }),    ({ "maxsec", Getopt.HAS_ARG, "-s,--max-seconds"/"," }),    ({ "tests", Getopt.HAS_ARG, "-t,--tests"/"," }), -  ({ "json", Getopt.NO_ARG, "-j,--json"/"," }), -  ({ "compare", Getopt.HAS_ARG, "-c,--compare"/"," }), +  ({ "json", Getopt.NO_ARG, "-j,--json"/"," }), +  ({ "compare", Getopt.HAS_ARG, "-c,--compare"/"," }), +  ({ "list", Getopt.NO_ARG, "-l,--list"/"," }),    })), array opt)    {    switch(opt[0])    {    case "json":    json = true;    break;    case "compare":    /* Convenience: When using make benchmark there will be some    junk output before the actual json.
pike.git/lib/modules/Tools.pmod/Standalone.pmod/benchmark.pike:83:    comparison = Standards.JSON.decode( data );    break;    case "help":    write(help, sizeof(tests));    return 0;    case "maxsec":    seconds_per_test = (int)opt[1];    break;    case "tests":    test_globs = opt[1] / ","; +  break; +  case "list": +  write("Available tests:\n%{ %s\n%}", +  sort(indices(tests)-({"Overhead"}))); +  return 0; +  break;    }    }    if( json )    write("{\n");    else if( !comparison )    write("-"*59+"\n%-40s%19s\n"+"-"*59+"\n",    "Test","Result");    else    write("-"*65+"\n%-40s%18s%7s\n"+"-"*65+"\n",    "Test","Result","Change");
pike.git/lib/modules/Tools.pmod/Standalone.pmod/benchmark.pike:134:    int on = comparison[id]->n_over_time;    if( !on )    write( dot(res->readable,19,false,odd)+"\n");    else    {    int diff = res->n_over_time - on;    float pct = diff*100.0 / on;    total_pct += pct;    if( isatty )    write( color( pct ) ); -  write("%40s%s %5.1f%%\n", -  dot(id,40,true,odd=!odd), -  dot(res->readable,18,false,odd), +  write("%42s%s %5.1f%%\n", +  dot(id,42,true,odd=!odd), +  dot(res->readable,16,false,odd),    pct);    if( isatty ) write( "\e[0m" );    }    }    else    { -  write(dot(id,40,true,odd=!odd) + -  dot(res->readable,19,false,odd)+"\n"); +  write(dot(id,42,true,odd=!odd) + +  dot(res->readable,17,false,odd)+"\n");    }    }    if( json )    write( "\n}\n");    else if( comparison )    {    write("-"*65+"\n"+    " "*40+"%24.1f%%\n"+    "-"*65+"\n",    total_pct / n_tests);    }    else -  write("-"*58+"\n"); +  write("-"*59+"\n");   } -  +