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

version» Context lines:

pike.git/lib/modules/Tools.pmod/Standalone.pmod/benchmark.pike:45:    return "\e[31;1m";    if( pct > 10 )    return "\e[33;1m";    return "";    }    if( pct < -10 )    return "\e[32;1m" ;    return "";   }    - int(0..) main(int num, array(string) args) - { -  mapping(string:Tools.Shoot.Test) tests= Tools.Shoot.tests(); -  int seconds_per_test = 3; -  array(string) test_globs = ({"*"}); + mapping(string:Tools.Shoot.Test) tests;   bool json;   mapping comparison; -  + int seconds_per_test = 3; + array(string) test_globs = ({"*"});    -  + int main(int num, array(string) args) + { +  tests = Tools.Shoot.tests();    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"/"," }),    ({ "list", Getopt.NO_ARG, "-l,--list"/"," }),    })), array opt)    {    switch(opt[0])
pike.git/lib/modules/Tools.pmod/Standalone.pmod/benchmark.pike:81:    string data = Stdio.read_file( opt[1] );    if( !data )    exit(1,"Failed to read comparison file %q\n",    combine_path( getcwd(), opt[1] ));    if( sscanf( data, "%*[^{]{%s", data ) )    data = "{"+data;    comparison = Standards.JSON.decode( data );    break;    case "help":    write(help, sizeof(tests)); +  write("\nAvailable tests:\n%{ %s\n%}", sort(indices(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");    -  +  call_out(run_tests, 0); +  return -1; + } +  + void run_tests() + { +  mixed err = catch {    /* Run overhead check first. */    float overhead_time;    array(string) to_run = glob(test_globs,sort(indices (tests)-({"Overhead"})));    mapping res = Tools.Shoot.run( tests["Overhead"], 1, 0.0 );    float total_pct;    int n_tests;    overhead_time = res->time / res->n;    bool odd;    bool isatty = Stdio.Terminfo.is_tty();   
pike.git/lib/modules/Tools.pmod/Standalone.pmod/benchmark.pike:168:    write( "\n}\n");    else if( comparison )    {    write("-"*65+"\n"+    " "*40+"%24.1f%%\n"+    "-"*65+"\n",    total_pct / n_tests);    }    else    write("-"*59+"\n"); +  }; +  if( err ) +  { +  write("\n"+describe_backtrace(err)); +  exit(1);    } -  +  exit(0); + }