forked from AlaSQL/alasql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test143.js
119 lines (107 loc) · 2.75 KB
/
test143.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
if (typeof exports === 'object') {
var assert = require('assert');
var alasql = require('..');
} else {
__dirname = '.';
}
describe('Test 143 streamfn', function() {
it('1. Create database', function(done) {
alasql('CREATE DATABASE test143; use test143');
done();
});
it('3. INNER JOIN on stream', function(done) {
test143(true);
alasql.databases[alasql.useid].dbversion++;
test143(false);
alasql.databases[alasql.useid].dbversion++;
// test143(true);
// test143(false);
// test143(true);
//console.log(res.length);
done();
});
it('99. Drop database', function(done) {
alasql('DROP DATABASE test143');
done();
});
});
function test143(dontcache) {
var nc1 = 0,
nc2 = 0,
nc3 = 0;
var myfn = function(i) {
nc1++;
if (i >= 100) return;
return {a: i, b: i + 2};
};
myfn.dontcache = dontcache;
var myfn2 = function(i) {
nc2++;
if (i >= 100) return;
for (var k = 0; k < 10; k++) {
Math.random();
}
return {a: i % 25 + 1, c: (i + 1) * 10};
};
myfn2.dontcache = dontcache;
// myfn3.dontcache = true;
var tm = Date.now();
//if(true) {
var res = alasql('select q.a, q.b, t.a as ta, t.c from ? q INNER join ? t using a', [
myfn,
myfn2,
]);
nc3 += res.length;
//console.table(res);
// console.log('INNER',res.length);
//if(false) {
var res = alasql('select q.a, q.b, t.a as ta, t.c from ? q SEMI join ? t using a', [
myfn,
myfn2,
]);
nc3 += res.length;
//console.table(res);
//console.log('SEMI', res.length);
//}
var res = alasql('select q.a, q.b, t.a as ta, t.c from ? q ANTI join ? t using a', [
myfn,
myfn2,
]);
nc3 += res.length;
//console.table(res);
//console.log('ANTI', res.length);
//if(true) {
var res = alasql('select q.a, q.b, t.a as ta, t.c from ? q LEFT join ? t using a', [
myfn,
myfn2,
]);
nc3 += res.length;
//console.table(res);
//console.log('LEFT',res.length);
// assert(res.length == 13013);
var res = alasql('select q.a, q.b, t.a as ta, t.c from ? q RIGHT join ? t using a', [
myfn,
myfn2,
]);
nc3 += res.length;
//console.table(res);
//console.log('RIGHT',res.length);
//assert(res.length == 13039);
var res = alasql('select q.a, q.b, t.a as ta, t.c from ? q OUTER join ? t using a', [
myfn,
myfn2,
]);
nc3 += res.length;
//console.table(res);
//console.log('OUTER',res.length);
// assert(res.length == 13039);
//}
//}
// var res = alasql('select q.a, q.b, t.c from ? q OUTER join ? t using a '+
// 'EXCEPT select q.a, q.b, t.c from ? q LEFT join ? t using a',[myfn,myfn2,myfn,myfn2]);
// console.log(res);
// console.log(res);
tm = Date.now() - tm;
// console.log(tm);
// console.log(dontcache, nc1,nc2, nc3, tm/nc2);
}