Skip to content
Snippets Groups Projects
Select Git revision
  • c29be5792029f0c47e54f6a1b49f1a49a93085f4
  • master default protected
  • 9.0
  • marcus/wix3
  • 8.0
  • nt-tools
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • v8.0.2020
  • v8.0.2018
  • v8.0.2016
  • v8.0.2014
  • v8.0.2012
  • v8.0.2008
  • v8.0.2006
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
41 results

module.pmod

Blame
  • module.pmod 2.13 KiB
    /* 
     *    Shootouts
     *        or
     * Pike speed tests
     *
     */
    
    #pike __REAL_VERSION__
    
    import ".";
    
    
    string format_big_number(int i)
    {
        if( i > 10000000000 )
            return i/1000000000+"G";
        if( i > 10000000 )
            return i/1000000+"M";
        if( i > 10000 )
            return i/1000+"k";
    
        return (string)i;
    }
    
    // This function runs the actual test, it is started in a sub-process from run.
    void run_sub( Test test, int maximum_seconds, float overhead)
    {
        float tg=0.0;
        int testntot=0;
        int nloops = 0;
        int norm;
        for (;;nloops++)
        {
            int start_cpu = gethrvtime();
            testntot += test->perform();
            tg += (gethrvtime()-start_cpu) / 1000000.0;
            if (tg >= maximum_seconds) break;
        }
    
        norm = (int)(testntot/tg);
    
        string res = (test->present_n ?
                      test->present_n(testntot,nloops,tg,tg,1) :
                      format_big_number(norm)+"/s");
    
    
        write( Standards.JSON.encode( ([ "time":tg,"loops":nloops,"n":testntot,"readable":res,"n_over_time":norm ]) )+"\n" );
    }
    
    private mapping(string:Test) _tests;
    private mapping(Test:string) rtests;
    
    mapping(string:Test) tests()
    {
      if( !_tests )
      {
        _tests = ([]);
        rtests = ([]);
        foreach (indices(Tools.Shoot), string test)
        {
          program p;
          Test t;
          if ((programp(p=Tools.Shoot[test])) &&  (t=p())->perform)
          {
            if( !t->name )
              exit(1,"The test %O does not have a name\n", t );
            if( _tests[t->name] )
              exit(1,"The tests %O and %O have the same name\n", t, _tests[t->name] );
            _tests[t->name]=t;
            rtests[t] = test;