⍝ Timing test script for [append] and [retain]:
⍝
⍝     test 'append_retain'      ⍝ performance timing test.
⍝   1 test 'append_retain'      ⍝ performance timing test (show progress).
⍝
⍝     set [loops] and [rows] to suit your machine:

    getenv←{⍎⊃(0=⎕nc ⍵)↓ ⍵ '⍺'}                 ⍝ get environment variable.

    loops ← 1000 getenv 'loops'                 ⍝ default 1000 loops.
    rows  ← 1000 getenv 'rows'                  ⍝ default 1000-row table.
    nest  ←    0 getenv 'nest'                  ⍝ default simple fields.

    +ddb.remove'ddb test'                       ⍝ ensure file removed.
0
    chars←'chars'  80, 10 × 1-2×nest            ⍝ char vectors
    ints ←'ints'  323                           ⍝ int  scalars
    doubs←'doubs' 645, 2 4 × 1-2×nest           ⍝ doub matrices

    tab←'ddb test' ddb.create chars ints doubs  ⍝ create table.

    enclose←{nest:⊂[1↓⍳⍴⍴⍵]⍵ ⋄ ⍵}               ⍝ enclose if nested.

    cvals←enclose rows 10⍴⎕a                    ⍝ char vector values.
    ivals←⍳rows                                 ⍝ int  scalar values.
    dvals←enclose rows 2 4⍴*1                   ⍝ doub matrix values.

    vals←cvals ivals dvals                      ⍝ values for all fields.

    app←{tab ddb.append vals}                   ⍝ re-append values.
    ret←{tab ddb.retain 0   }                   ⍝ remove all rows.

    {}⎕wa                                       ⍝ compact for consistent test.

    {} {0}∘ret∘app¨time ⍳loops                  ⍝ append/compress timing test.

    +ddb.remove tab                             ⍝ remove table.
1
⍝   
⍝   Back to: Contents