(command.CommandList
  children: [
    (C {(KW_Set set)} {(-o)} {(nounset)})
    (C {(KW_Set set)} {(-o)} {(pipefail)})
    (C {(KW_Set set)} {(-o)} {(errexit)})
    (C {(source)} {(test/common.sh)})
    (C {(source)} {(benchmarks/common.sh)})
    (C {(readonly)} {(Lit_VarLike 'BASE_DIR=') (_tmp/vm-baseline)})
    (command.ShFunction
      name: measure
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(Lit_VarLike 'provenance=') ($ VSub_Number '$1')})
            (C {(local)} 
              {(Lit_VarLike 'base_dir=') 
                (braced_var_sub
                  token: <VSub_Number 2>
                  suffix_op: 
                    (suffix_op.Unary
                      op_id: VTest_ColonHyphen
                      arg_word: {(_tmp) (Lit_Slash /) (vm-baseline)}
                    )
                )
              }
            )
            (C {(local)} 
              {(Lit_VarLike 'name=') 
                (command_sub
                  left_token: <Left_DollarParen '$('>
                  command_list: 
                    (command.CommandList
                      children: [(C {(basename)} {($ VSub_DollarName '$provenance')})]
                    )
                )
              }
            )
            (C {(local)} 
              {(Lit_VarLike 'prefix=') 
                (braced_var_sub
                  token: <VSub_Name name>
                  suffix_op: (suffix_op.Unary op_id:VOp1_Percent arg_word:{(.provenance.txt)})
                )
              }
            )
            (C {(local)} 
              {(Lit_VarLike 'host=') 
                (command_sub
                  left_token: <Left_DollarParen '$('>
                  command_list: (command.CommandList children:[(C {(hostname)})])
                )
              }
            )
            (C {(local)} 
              {(Lit_VarLike 'out_dir=') 
                (DQ ($ VSub_DollarName '$base_dir') (/) ($ VSub_DollarName '$prefix'))
              }
            )
            (C {(mkdir)} {(-p)} {($ VSub_DollarName '$out_dir')})
            (command.Pipeline
              children: [
                (C {(cat)} {($ VSub_DollarName '$provenance')})
                (command.WhileUntil
                  keyword: <KW_While while>
                  cond: [
                    (command.Sentence
                      child: (C {(read)} {(_)} {(_)} {(_)} {(sh_path)} {(shell_hash)})
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  body: 
                    (command.DoGroup
                      children: [
                        (C {(local)} 
                          {(Lit_VarLike 'sh_name=') 
                            (command_sub
                              left_token: <Left_DollarParen '$('>
                              command_list: 
                                (command.CommandList
                                  children: [(C {(basename)} {($ VSub_DollarName '$sh_path')})]
                                )
                            )
                          }
                        )
                        (C {(local)} 
                          {(Lit_VarLike 'out=') 
                            (DQ ($ VSub_DollarName '$out_dir') (/) (${ VSub_Name sh_name) (-) 
                              (${ VSub_Name shell_hash) (.txt)
                            )
                          }
                        )
                        (command.Simple
                          words: [
                            {($ VSub_DollarName '$sh_path')}
                            {(-c)}
                            {(SQ <'sleep 0.001; cat /proc/$$/status'>)}
                          ]
                          redirects: [
                            (redir.Redir
                              op: <Redir_Great '>'>
                              fd: 16777215
                              arg_word: {($ VSub_DollarName '$out')}
                            )
                          ]
                        )
                      ]
                    )
                )
              ]
              negated: F
            )
            (C {(echo)})
            (C {(echo)} {(DQ ($ VSub_DollarName '$out_dir') (':'))})
            (C {(ls)} {(-l)} {($ VSub_DollarName '$out_dir')})
          ]
        )
    )
    (command.ShFunction
      name: demo
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(-a)} 
              {(Lit_VarLike 'job_dirs=') 
                (sh_array_literal
                  left: <Op_LParen '('>
                  words: [{($ VSub_DollarName '$BASE_DIR') (/lisa.2017-) (Lit_Star '*')}]
                )
              }
            )
            (C {(local)} {(Lit_VarLike 'dir1=') ($ VSub_DollarName '$BASE_DIR') (/stage1)})
            (C {(local)} {(Lit_VarLike 'dir2=') ($ VSub_DollarName '$BASE_DIR') (/stage2)})
            (C {(mkdir)} {(-p)} {($ VSub_DollarName '$dir1')} {($ VSub_DollarName '$dir2')})
            (command.Simple
              words: [
                {(benchmarks/virtual_memory.py)}
                {(baseline)}
                {
                  (braced_var_sub
                    token: <VSub_Name job_dirs>
                    bracket_op: 
                      (bracket_op.ArrayIndex
                        expr: 
                          (arith_expr.Unary
                            op_id: Node_UnaryMinus
                            child: (arith_expr.ArithWord w:{(Lit_Digits 1)})
                          )
                      )
                  )
                }
              ]
              redirects: [
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {($ VSub_DollarName '$dir1') (/vm-baseline.csv)}
                )
              ]
            )
            (C {(benchmarks/report.R)} {(vm-baseline)} {($ VSub_DollarName '$dir1')} 
              {($ VSub_DollarName '$dir2')}
            )
          ]
        )
    )
    (command.ShFunction
      name: stage1
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} 
              {(Lit_VarLike 'raw_dir=') 
                (braced_var_sub
                  token: <VSub_Number 1>
                  suffix_op: 
                    (suffix_op.Unary
                      op_id: VTest_ColonHyphen
                      arg_word: {($ VSub_DollarName '$BASE_DIR') (Lit_Slash /) (raw)}
                    )
                )
              }
            )
            (C {(local)} {(Lit_VarLike 'out=') ($ VSub_DollarName '$BASE_DIR') (/stage1)})
            (C {(mkdir)} {(-p)} {($ VSub_DollarName '$out')})
            (C {(local)} {(-a)} 
              {(Lit_VarLike 'm1=') 
                (sh_array_literal
                  left: <Op_LParen '('>
                  words: [{(../benchmark-data/vm-baseline/flanders.) (Lit_Star '*')}]
                )
              }
            )
            (C {(local)} {(-a)} 
              {(Lit_VarLike 'm2=') 
                (sh_array_literal
                  left: <Op_LParen '('>
                  words: [{(../benchmark-data/vm-baseline/lisa.) (Lit_Star '*')}]
                )
              }
            )
            (C {(local)} {(-a)} 
              {(Lit_VarLike 'latest=') 
                (sh_array_literal
                  left: <Op_LParen '('>
                  words: [
                    {
                      (braced_var_sub
                        token: <VSub_Name m1>
                        bracket_op: 
                          (bracket_op.ArrayIndex
                            expr: 
                              (arith_expr.Unary
                                op_id: Node_UnaryMinus
                                child: (arith_expr.ArithWord w:{(Lit_Digits 1)})
                              )
                          )
                      )
                    }
                    {
                      (braced_var_sub
                        token: <VSub_Name m2>
                        bracket_op: 
                          (bracket_op.ArrayIndex
                            expr: 
                              (arith_expr.Unary
                                op_id: Node_UnaryMinus
                                child: (arith_expr.ArithWord w:{(Lit_Digits 1)})
                              )
                          )
                      )
                    }
                  ]
                )
              }
            )
            (command.Pipeline
              children: [
                (C {(benchmarks/virtual_memory.py)} {(baseline)} 
                  {
                    (DQ 
                      (braced_var_sub
                        token: <VSub_Name latest>
                        bracket_op: (bracket_op.WholeArray op_id:Lit_At)
                      )
                    )
                  }
                )
                (C {(tee)} {($ VSub_DollarName '$out') (/vm-baseline.csv)})
              ]
              negated: F
            )
          ]
        )
    )
    (command.ShFunction
      name: print-report
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(Lit_VarLike 'in_dir=') ($ VSub_Number '$1')})
            (C {(local)} {(Lit_VarLike 'base_url=') (SQ <../../web>)})
            (command.Simple
              words: [{(cat)}]
              redirects: [
                (redir.HereDoc
                  op: <Redir_DLess '<<'>
                  fd: 16777215
                  here_begin: {(EOF)}
                  here_end_span_id: 520
                  stdin_parts: [
                    ('<!DOCTYPE html>\n')
                    ('<html>\n')
                    ('  <head>\n')
                    ('    <title>Virtual Memory Baseline</title>\n')
                    ('    <script type=')
                    (Right_DoubleQuote '"')
                    (text/javascript)
                    (Right_DoubleQuote '"')
                    (' src=')
                    (Right_DoubleQuote '"')
                    ($ VSub_DollarName '$base_url')
                    (/table/table-sort.js)
                    (Right_DoubleQuote '"')
                    ('></script>\n')
                    ('    <link rel=')
                    (Right_DoubleQuote '"')
                    (stylesheet)
                    (Right_DoubleQuote '"')
                    (' type=')
                    (Right_DoubleQuote '"')
                    (text/css)
                    (Right_DoubleQuote '"')
                    (' href=')
                    (Right_DoubleQuote '"')
                    ($ VSub_DollarName '$base_url')
                    (/table/table-sort.css)
                    (Right_DoubleQuote '"')
                    (' />\n')
                    ('    <link rel=')
                    (Right_DoubleQuote '"')
                    (stylesheet)
                    (Right_DoubleQuote '"')
                    (' type=')
                    (Right_DoubleQuote '"')
                    (text/css)
                    (Right_DoubleQuote '"')
                    (' href=')
                    (Right_DoubleQuote '"')
                    ($ VSub_DollarName '$base_url')
                    (/benchmarks.css)
                    (Right_DoubleQuote '"')
                    (' />\n')
                    ('\n')
                    ('  </head>\n')
                    ('  <body>\n')
                    ('    <p id=')
                    (Right_DoubleQuote '"')
                    (home-link)
                    (Right_DoubleQuote '"')
                    ('>\n')
                    ('      <a href=')
                    (Right_DoubleQuote '"')
                    (/)
                    (Right_DoubleQuote '"')
                    ('>oilshell.org</a>\n')
                    ('    </p>\n')
                    ('    <h2>Virtual Memory Baseline</h2>\n')
                    ('\n')
                    ('    <h3>Memory Used at Startup (MB)</h3>\n')
                    ('\n')
                    ('    <p>Running under <code>osh-ovm</code>.  Memory usage is measured in MB\n')
                    ('    (powers of 10), not MiB (powers of 2).</p>\n')
                    ('\n')
                  ]
                )
              ]
            )
            (C {(csv2html)} {($ VSub_DollarName '$in_dir') (/vm-baseline.csv)})
            (command.Simple
              words: [{(cat)}]
              redirects: [
                (redir.HereDoc
                  op: <Redir_DLess '<<'>
                  fd: 16777215
                  here_begin: {(EOF)}
                  here_end_span_id: 540
                  stdin_parts: [('    <!-- <h3>Shell and Host Details</h3> -->\n')]
                )
              ]
            )
            (command.Simple
              words: [{(cat)}]
              redirects: [
                (redir.HereDoc
                  op: <Redir_DLess '<<'>
                  fd: 16777215
                  here_begin: {(EOF)}
                  here_end_span_id: 559
                  stdin_parts: [('  </body>\n') ('</html>\n')]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: parser-dump-demo
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(Lit_VarLike 'out_dir=') (_tmp/virtual-memory)})
            (C {(mkdir)} {(-p)} {($ VSub_DollarName '$out_dir')})
            (C {(local)} {(Lit_VarLike 'input=') (benchmarks/testdata/abuild)})
            (C {(bin/osh)} {(--parser-mem-dump)} {($ VSub_DollarName '$out_dir') (/parser.txt)} {(-n)} 
              {(--ast-format)} {(none)} {($ VSub_DollarName '$input')}
            )
            (C {(grep)} {(SQ <'^Vm'>)} {($ VSub_DollarName '$out_dir') (/parser.txt)})
          ]
        )
    )
    (command.ShFunction
      name: runtime-dump-demo
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(Lit_VarLike 'out_dir=') (_tmp/virtual-memory)})
            (C {(mkdir)} {(-p)} {($ VSub_DollarName '$out_dir')})
            (C {(bin/osh)} {(--parser-mem-dump)} {($ VSub_DollarName '$out_dir') (/parser.txt)} 
              {(--runtime-mem-dump)} {($ VSub_DollarName '$out_dir') (/runtime.txt)} {(-c)} {(SQ <'echo $(echo hi)'>)}
            )
            (C {(grep)} {(SQ <'^Vm'>)} {($ VSub_DollarName '$out_dir') (/parser.txt)} 
              {($ VSub_DollarName '$out_dir') (/runtime.txt)}
            )
          ]
        )
    )
    (C {(DQ ($ VSub_At '$@'))})
  ]
)