Browse Source

Redid recent Ur/Web changes

Adam Chlipala 11 years ago
parent
commit
951bb1d834

+ 3 - 0
.gitignore

@@ -69,3 +69,6 @@ benchmark.cfg
 # go
 # go
 go/pkg/*
 go/pkg/*
 beego/pkg/*
 beego/pkg/*
+
+# urweb
+urweb/*.exe

+ 0 - 28
config/create-postgres-urweb.sql

@@ -1,28 +0,0 @@
-DROP TABLE IF EXISTS uw_Bench_world;
-
-CREATE TABLE uw_Bench_world AS
-SELECT uw_id::int8, trunc(random()*9999+1)::int8 AS uw_randomnumber
-FROM generate_series(1,10000) AS uw_id;
-
-ALTER TABLE uw_Bench_world ADD PRIMARY KEY (uw_id);
-ALTER TABLE uw_Bench_world ALTER COLUMN uw_randomnumber SET NOT NULL;
-
-DROP TABLE IF EXISTS uw_Bench_fortune;
-CREATE TABLE uw_Bench_fortune (
-  uw_id int8 NOT NULL,
-  uw_message text NOT NULL,
-  PRIMARY KEY (uw_id)
-);
-
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (11, '<script>alert("This should not be displayed in a browser alert box.")</script>');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (4, 'A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (5, 'A computer program does what you tell it to do, not what you want it to do.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (2, 'A computer scientist is someone who fixes things that aren''t broken.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (8, 'A list is only as strong as its weakest link. — Donald Knuth');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (3, 'After enough decimal places, nobody gives a damn.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (7, 'Any program that runs right is obsolete.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (10, 'Computers make very fast, very accurate mistakes.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (6, 'Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (9, 'Feature: A bug with seniority.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (1, 'fortune: No such file or directory');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (12, 'フレームワークのベンチマーク');

+ 1 - 2
toolset/setup/linux/installer.py

@@ -202,7 +202,7 @@ class Installer:
     # Ur/Web
     # Ur/Web
     # Min version: ac1be85e91ad --- HTML5 directive
     # Min version: ac1be85e91ad --- HTML5 directive
 
 
-    self.__run_command("hg clone http://hg.impredicative.com/urweb/")
+    self.__run_command("hg clone -rac1be85e91ad http://hg.impredicative.com/urweb")
     self.__run_command("./autogen.sh", cwd="urweb")
     self.__run_command("./autogen.sh", cwd="urweb")
     self.__run_command("./configure", cwd="urweb")
     self.__run_command("./configure", cwd="urweb")
     self.__run_command("make", cwd="urweb")
     self.__run_command("make", cwd="urweb")
@@ -455,7 +455,6 @@ class Installer:
     sudo useradd benchmarkdbuser -p benchmarkdbpass
     sudo useradd benchmarkdbuser -p benchmarkdbpass
     sudo -u postgres psql template1 < create-postgres-database.sql
     sudo -u postgres psql template1 < create-postgres-database.sql
     sudo -u benchmarkdbuser psql hello_world < create-postgres.sql
     sudo -u benchmarkdbuser psql hello_world < create-postgres.sql
-    sudo -u benchmarkdbuser psql hello_world < create-postgres-urweb.sql
 
 
     sudo -u postgres -H /etc/init.d/postgresql stop
     sudo -u postgres -H /etc/init.d/postgresql stop
     sudo mv postgresql.conf /etc/postgresql/9.1/main/postgresql.conf
     sudo mv postgresql.conf /etc/postgresql/9.1/main/postgresql.conf

BIN
urweb/bench.exe


+ 13 - 23
urweb/bench.ur

@@ -17,25 +17,15 @@ fun addHeaders () =
   setHeader (blessResponseHeader "Date") (timef "%a, %d %b %Y %H:%M:%S GMT" n);
   setHeader (blessResponseHeader "Date") (timef "%a, %d %b %Y %H:%M:%S GMT" n);
   setHeader (blessResponseHeader "Server") "Ur/Web"
   setHeader (blessResponseHeader "Server") "Ur/Web"
 
 
-(** This function handles processing of a "queries" query string parameter to a
-  * few of the benchmarks.  The URL representation is mandated by the spec, so
-  * we don't get to use Ur/Web's standard handling of parameters.  Instead,
-  * there's some manual parsing. :-( *)
-fun parseQueries oqs : int =
-  let
-    val qt = case oqs of
-        None => Some ("queries", "1")
-      | Some qs => String.split (show qs) #"="
-    val on = case qt of
-        Some ("queries", x) => read x
-      | _ => Some 1
-  in
-    case on of
-      None => 1
-    | Some x => if x > 500 then 500
-                else if x < 1 then 1
-                else x
-  end
+(** This function handles processing of a "queries" string parameter to a few of
+  * the benchmarks.  The URL representation is mandated by the spec, so we need
+  * to do some manual parsing to handle malformed inputs. :-( *)
+fun parseQueries s =
+    case read s of
+        None => 1
+      | Some n => if n > 500 then 500
+                  else if n < 1 then 1
+                  else n
 
 
 (** Most of the benchmarks return results as JSON.
 (** Most of the benchmarks return results as JSON.
   * Here's a handy function to automate wrapping an arbitrary JSONable value as
   * Here's a handy function to automate wrapping an arbitrary JSONable value as
@@ -96,8 +86,8 @@ fun db () =
 
 
 (** * Test type 3: Multiple database queries *)
 (** * Test type 3: Multiple database queries *)
 
 
-fun queries oqs =
-  rows <- List.tabulateM (fn _ => n <- random_id; world_find n) (parseQueries oqs);
+fun queries s =
+  rows <- List.tabulateM (fn _ => n <- random_id; world_find n) (parseQueries s);
   returnJson rows
   returnJson rows
 
 
 
 
@@ -133,9 +123,9 @@ fun fortunes () =
 
 
 (** * Test type 5: Database updates *)
 (** * Test type 5: Database updates *)
 
 
-fun updates oqs =
+fun updates s =
   rows <- List.tabulateM (fn _ => n <- random_id; world_find n)
   rows <- List.tabulateM (fn _ => n <- random_id; world_find n)
-                         (parseQueries oqs);
+                         (parseQueries s);
   rows' <- List.mapM (fn r => n <- random_id;
   rows' <- List.mapM (fn r => n <- random_id;
                          return (r -- #RandomNumber ++ {RandomNumber = n}))
                          return (r -- #RandomNumber ++ {RandomNumber = n}))
                      rows;
                      rows;

+ 3 - 1
urweb/bench.urp

@@ -1,11 +1,13 @@
 library meta
 library meta
 database dbname=hello_world user=benchmarkdbuser password=benchmarkdbpass host=localhost
 database dbname=hello_world user=benchmarkdbuser password=benchmarkdbpass host=localhost
-rewrite url Bench/*
+rewrite all Bench/*
 allow responseHeader Date
 allow responseHeader Date
 allow responseHeader Server
 allow responseHeader Server
 allow mime application/json
 allow mime application/json
 allow mime text/plain
 allow mime text/plain
 safeGet updates
 safeGet updates
+noMangleSql
+html5
 
 
 $/list
 $/list
 $/string
 $/string

+ 4 - 4
urweb/bench.urs

@@ -1,6 +1,6 @@
 val json : unit -> transaction page
 val json : unit -> transaction page
-val plaintext : unit -> transaction page
 val db : unit -> transaction page
 val db : unit -> transaction page
-val queries: option queryString -> transaction page
-val fortunes: unit -> transaction page
-val updates: option queryString -> transaction page
+val queries : string -> transaction page
+val fortunes : unit -> transaction page
+val updates : string -> transaction page
+val plaintext : unit -> transaction page

+ 36 - 5
urweb/benchmark_config

@@ -4,11 +4,25 @@
     "default": {
     "default": {
       "setup_file": "setup",
       "setup_file": "setup",
       "json_url": "/json",
       "json_url": "/json",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "None",
+      "framework": "ur/web",
+      "language": "Ur",
+      "orm": "Micro",
+      "platform": "Ur/Web",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux"
+    },
+    "postgres": {
+      "setup_file": "setup",
       "db_url": "/db",
       "db_url": "/db",
-      "query_url": "/queries?queries=",
+      "query_url": "/queries/",
       "fortune_url": "/fortunes",
       "fortune_url": "/fortunes",
-      "update_url": "/updates?queries=",
-      "plaintext_url": "/plaintext",
+      "update_url": "/updates/",
       "port": 8080,
       "port": 8080,
       "approach": "Realistic",
       "approach": "Realistic",
       "classification": "Fullstack",
       "classification": "Fullstack",
@@ -19,8 +33,25 @@
       "platform": "Ur/Web",
       "platform": "Ur/Web",
       "webserver": "None",
       "webserver": "None",
       "os": "Linux",
       "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "ur/web"
+      "database_os": "Linux"
+    },
+    "mysql": {
+      "setup_file": "setup_mysql",
+      "db_url": "/db",
+      "query_url": "/queries/",
+      "fortune_url": "/fortunes",
+      "update_url": "/updates/",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "MySQL",
+      "framework": "ur/web",
+      "language": "Ur",
+      "orm": "Micro",
+      "platform": "Ur/Web",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux"
     }
     }
   }]
   }]
 }
 }

+ 0 - 28
urweb/create-postgres.sql

@@ -1,28 +0,0 @@
-DROP TABLE IF EXISTS uw_Bench_world;
-
-CREATE TABLE uw_Bench_world AS
-SELECT uw_id::int8, trunc(random()*9999+1)::int8 AS uw_randomnumber
-FROM generate_series(1,10000) AS uw_id;
-
-ALTER TABLE uw_Bench_world ADD PRIMARY KEY (uw_id);
-ALTER TABLE uw_Bench_world ALTER COLUMN uw_randomnumber SET NOT NULL;
-
-DROP TABLE IF EXISTS uw_Bench_fortune;
-CREATE TABLE uw_Bench_fortune (
-  uw_id int8 NOT NULL,
-  uw_message text NOT NULL,
-  PRIMARY KEY (uw_id)
-);
-
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (11, '<script>alert("This should not be displayed in a browser alert box.")</script>');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (4, 'A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (5, 'A computer program does what you tell it to do, not what you want it to do.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (2, 'A computer scientist is someone who fixes things that aren''t broken.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (8, 'A list is only as strong as its weakest link. — Donald Knuth');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (3, 'After enough decimal places, nobody gives a damn.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (7, 'Any program that runs right is obsolete.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (10, 'Computers make very fast, very accurate mistakes.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (6, 'Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (9, 'Feature: A bug with seniority.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (1, 'fortune: No such file or directory');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (12, 'フレームワークのベンチマーク');

+ 0 - 14
urweb/fortune.sql

@@ -1,14 +0,0 @@
-CREATE TABLE uw_Bench_fortune(uw_id int8 NOT NULL, uw_message text NOT NULL,
-  PRIMARY KEY (uw_id));
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (11, '<script>alert("This should not be displayed in a browser alert box.")</script>');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (4, 'A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (5, 'A computer program does what you tell it to do, not what you want it to do.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (2, 'A computer scientist is someone who fixes things that aren''t broken.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (8, 'A list is only as strong as its weakest link. — Donald Knuth');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (3, 'After enough decimal places, nobody gives a damn.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (7, 'Any program that runs right is obsolete.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (10, 'Computers make very fast, very accurate mistakes.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (6, 'Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (9, 'Feature: A bug with seniority.');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (1, 'fortune: No such file or directory');
-INSERT INTO uw_Bench_fortune (uw_id, uw_message) VALUES (12, 'フレームワークのベンチマーク');

+ 8 - 8
urweb/setup.py

@@ -2,16 +2,16 @@ import subprocess
 import os
 import os
 
 
 def start(args, logfile, errfile):
 def start(args, logfile, errfile):
-  subprocess.check_call("urweb bench", shell=True, cwd="urweb", stderr=errfile, stdout=logfile)
-
-  threads = str(args.max_threads)
   conn_string = ('dbname=hello_world '
   conn_string = ('dbname=hello_world '
-                'user=benchmarkdbuser '
-                'password=benchmarkdbpass '
-                'host=' + args.database_host)
-  env = {'URWEB_PQ_CON': conn_string}
+                 'user=benchmarkdbuser '
+                 'password=benchmarkdbpass '
+                 'host=' + args.database_host)
+
+  subprocess.check_call("urweb -db \"" + conn_string + "\" bench", shell=True, cwd="urweb", stderr=errfile, stdout=logfile)
+
+  threads = str(args.max_threads * 2)
   subprocess.Popen("./bench.exe -q -k -t " + threads,
   subprocess.Popen("./bench.exe -q -k -t " + threads,
-                   env=env, shell=True, cwd="urweb", stderr=errfile, stdout=logfile)
+                   shell=True, cwd="urweb", stderr=errfile, stdout=logfile)
   return 0
   return 0
 
 
 def stop(logfile, errfile):
 def stop(logfile, errfile):

+ 27 - 0
urweb/setup_mysql.py

@@ -0,0 +1,27 @@
+import subprocess
+import os
+
+def start(args, logfile, errfile):
+  conn_string = ('dbname=hello_world '
+                 'user=benchmarkdbuser '
+                 'password=benchmarkdbpass '
+                 'host=' + args.database_host)
+
+  subprocess.check_call("urweb -dbms mysql -db \"" + conn_string + "\" bench", shell=True, cwd="urweb", stderr=errfile, stdout=logfile)
+
+  threads = str(args.max_threads * 2)
+  subprocess.Popen("./bench.exe -q -k -t " + threads,
+                   shell=True, cwd="urweb", stderr=errfile, stdout=logfile)
+  return 0
+
+def stop(logfile, errfile):
+  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p.communicate()
+  for line in out.splitlines():
+    if 'bench.exe' in line:
+      try:
+        pid = int(line.split(None, 2)[1])
+        os.kill(pid, 9)
+      except OSError:
+        pass
+  return 0

+ 0 - 1
urweb/source_code

@@ -1,3 +1,2 @@
 ./urweb/bench.ur
 ./urweb/bench.ur
 ./urweb/bench.urs
 ./urweb/bench.urs
-./urweb/bench.urp

+ 0 - 3
urweb/world.sql

@@ -1,3 +0,0 @@
-CREATE TABLE uw_Bench_world AS SELECT uw_id::int8, trunc(random()*9999+1)::int8 AS uw_randomnumber FROM generate_series(1,10000) AS uw_id;
-ALTER TABLE uw_Bench_world ADD PRIMARY KEY (uw_id);
-ALTER TABLE uw_Bench_world ALTER COLUMN uw_randomnumber SET NOT NULL;