Skip to content

Instantly share code, notes, and snippets.

@0racle
Created February 9, 2023 07:00
Show Gist options
  • Save 0racle/99179c000d66556b51d01830e1646e70 to your computer and use it in GitHub Desktop.
Save 0racle/99179c000d66556b51d01830e1646e70 to your computer and use it in GitHub Desktop.
TimeSpaceX wrapper for J

Defined like so

ts =: {{
    echo < 'timespacex * ', ": x
    result =. x&{{ y ; (8!:0) (x, 1) * x timespacex y }}@> cutopen y
    echo ,. ('expr';'time';'space') , result
}}

Run like so

a =: i. 4 4
1e6 ts '(<0 1) |: |. a';'(i. - # a)} a' 

Outputs like so

┌────────────────────┐
│timespacex * 1000000│
└────────────────────┘
┌──────────────┬────────┬─────┐
│expr          │time    │space│
├──────────────┼────────┼─────┤
│(<0 1) |: |. a│0.577596│1856 │
├──────────────┼────────┼─────┤
│(i. - # a)} a │0.446183│1536 │
└──────────────┴────────┴─────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment