⍝ Timing test script for [get]:
⍝
⍝     test 'get'            ⍝ performance timing test.
⍝   1 test 'get'            ⍝ 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                           ⍝ intg 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                            ⍝ intg scalar values.
    dvals←enclose rows 2 4⍴*1                   ⍝ doub matrix values.

    {}tab ddb.append cvals ivals dvals          ⍝ append some values.

    mask←(⍳rows)∘{⍺<rows|⍵}                     ⍝ mask for first ⍵ rows.

    get←{tab ddb.get (mask ⍵) tab.names}        ⍝ get all fields.

    {}⎕wa                                       ⍝ compact for consistent test.

    {}{0}∘get¨time ⍳loops                       ⍝ get timing test.

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