[Ur] little benchmark on querying a table only

Marc Weber marco-oweber at gmx.de
Mon Dec 20 00:08:55 EST 2010


PHP: 2.7 total

urweb (http): 

  benchmark PHP (run by apache) (5.3):
    ab -n 100 -c1 http://l/pg_speed.php  0.01s user 0.03s system 3% cpu 1.242 total

  benchmark ur (http):
    ab -n 100 -c1 http://l:8090/St/list  0.01s user 0.02s system 1% cpu 2.147 total

  benchmark ur (fastcgi):
    ab -n 100 -c1 http://l/fcgid/pg_fcgi.fcgi/St/list  0.01s user 0.02s system 1% cpu 2.522 total

  -c1 means no threading.
  data: 1000 rows


I know that that simple loop is a very bad benchmark.
Yet it surprises me that PHP is significantly faster than urweb.

CODE
==============
  ur:

        sequence s
        table t : { Id : int, S1 : string, S2:string, S3:string, S4:string }


        fun page title body =
          <xml>
            <head> <title>{[title]}</title> </head>
            <body>
              {body}
            </body>
          </xml>

        fun fill () =
            dml (DELETE FROM t WHERE 1=1);
            List.app ( fn i =>
              (nv <- nextval s;
              (dml (INSERT INTO t (Id, S1, S2, S3, S4) VALUES ({[nv]}, {["S1"]}, {["S2"]}, {["S3"]}, {["S4"]}))))
            ) (Enum.to 0 1000);
            return (page "fill" <xml>done</xml>)

        fun list() =
            xml <- queryX (SELECT * FROM t)
              (fn t => <xml>Id: {[t.T.Id]} S1: {[t.T.S1]} S2: {[t.T.S2]} S3: {[t.T.S3]} S4: {[t.T.S4]}<br/></xml>);
            return (page  "list" xml)

        fun main () = return (page "hello" <xml>
            <form><submit action={fill} value="fill"/></form>
            <form><submit action={list} value="list"/></form>
        </xml>)

  PHP:

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html>
        <head>
          <title>
          </title>
            <meta name="robots" content="index,nofollow" />
            <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        </head>
        <body>

        <?php
          $pg = pg_connect("dbname=simple_table");

          $res = pg_query($pg, "SELECT * FROM uw_st_t");

          while ($row = pg_fetch_row($res)) {
              echo "Id: {$row[0]} S1: {$row[1]} S2: {$row[2]} S3: {$row[3]} S4: {$row[4]}<br/>\n";
          };

        ?>
        </body>
        </html>



More information about the Ur mailing list