remove math.blas.syntax and merge parsing words into math.blas.vectors/matrices
[factor/jcg.git] / basis / db / tester / tester.factor
blob490f6bbef585093b581ad0f5799f38b9c7eb1410
1 ! Copyright (C) 2008 Slava Pestov, Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: concurrency.combinators db.pools db.sqlite db.tuples
4 db.types kernel math random threads tools.test db sequences
5 io prettyprint ;
6 IN: db.tester
8 TUPLE: test-1 id a b c ;
10 test-1 "TEST1" {
11    { "id" "ID" INTEGER +db-assigned-id+ }
12    { "a" "A" { VARCHAR 256 } +not-null+ }
13    { "b" "B" { VARCHAR 256 } +not-null+ }
14    { "c" "C" { VARCHAR 256 } +not-null+ }
15 } define-persistent
17 TUPLE: test-2 id x y z ;
19 test-2 "TEST2" {
20    { "id" "ID" INTEGER +db-assigned-id+ }
21    { "x" "X" { VARCHAR 256 } +not-null+ }
22    { "y" "Y" { VARCHAR 256 } +not-null+ }
23    { "z" "Z" { VARCHAR 256 } +not-null+ }
24 } define-persistent
26 : sqlite-test-db ( -- db ) "test.db" <sqlite-db> ;
27 : test-db ( -- db ) "test.db" <sqlite-db> ;
29 : db-tester ( test-db -- )
30     [
31         [
32             test-1 ensure-table
33             test-2 ensure-table
34         ] with-db
35     ] [
36         10 [
37             drop
38             10 [
39                 dup [
40                     f 100 random 100 random 100 random test-1 boa
41                     insert-tuple yield
42                 ] with-db
43             ] times
44         ] with parallel-each
45     ] bi ;
47 : db-tester2 ( test-db -- )
48     [
49         [
50             test-1 ensure-table
51             test-2 ensure-table
52         ] with-db
53     ] [
54         <db-pool> [
55             10 [
56                 10 [
57                     f 100 random 100 random 100 random test-1 boa
58                     insert-tuple yield
59                 ] times
60             ] parallel-each
61         ] with-pooled-db
62     ] bi ;