1
+ const cds = require ( '../../cds.js' )
2
+ const { Readable } = require ( 'stream' )
3
+
4
+ const { gen, rows } = require ( './data.js' )
5
+ const { run } = require ( './perf.js' )
6
+
7
+ describe ( 'Map - CLOB' , ( ) => {
8
+ const { expect } = cds . test ( __dirname , __dirname + '/clob.cds' )
9
+
10
+ test ( 'perf' , async ( ) => {
11
+ const { Map } = cds . entities
12
+
13
+ console . log ( 'Starting Insert...' )
14
+ const s = performance . now ( )
15
+ await INSERT ( Readable . from ( gen ( ) , { objectMode : false } ) ) . into ( Map )
16
+ const dur = performance . now ( ) - s
17
+ console . log ( 'Finished Insert:' , dur , '(' , ( rows / dur ) , 'rows/ms)' )
18
+
19
+ const [ { count : rowCount } ] = await cds . ql `SELECT count() from ${ Map } `
20
+ expect ( rowCount ) . eq ( rows )
21
+ console . log ( 'Validated Insert.' )
22
+
23
+ /* HANA
24
+ Starting Insert...
25
+ Finished Insert: 10261.39113 ( 3.19332920701172 rows/ms)
26
+ Validated Insert.
27
+ $top=30 avg: 3 ms cold: 30 ms
28
+ ID='1' avg: 3 ms cold: 34 ms
29
+ */
30
+
31
+ /* postgres
32
+ Starting Insert...
33
+ Finished Insert: 13024.595653 ( 2.51585545325182 rows/ms)
34
+ Validated Insert.
35
+ $top=30 avg: 6 ms cold: 9 ms
36
+ ID='1' avg: 0 ms cold: 4 ms
37
+ */
38
+
39
+ /* sqlite
40
+ Starting Insert...
41
+ Finished Insert: 2072.096841 ( 15.813932704123069 rows/ms)
42
+ Validated Insert.
43
+ $top=30 avg: 1 ms cold: 2 ms
44
+ ID='1' avg: 0 ms cold: 1 ms
45
+ */
46
+
47
+ await run ( '$top=30' , cds . ql `SELECT ID, map FROM ${ Map } LIMIT ${ 30 } ` )
48
+ await run ( `ID='1'` , cds . ql `SELECT ID, map FROM ${ Map } WHERE ID=${ '1' } LIMIT ${ 1 } ` )
49
+ } )
50
+
51
+ } )
0 commit comments