(command.CommandList
  children: [
    (C {<set>} {<-o>} {<nounset>})
    (C {<set>} {<-o>} {<pipefail>})
    (C {<set>} {<-o>} {<errexit>})
    (C {<source>} {<'test/common.sh'>})
    (C {<source>} {<'benchmarks/common.sh'>})
    (C {<readonly>} {<Id.Lit_VarLike 'BASE_DIR='> <'_tmp/vm-baseline'>})
    (command.ShFunction
      name: measure
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'provenance='> ($ Id.VSub_Number '$1')})
            (C {<local>} 
              {<Id.Lit_VarLike 'base_dir='> 
                (braced_var_sub
                  token: <Id.VSub_Number 2>
                  suffix_op: 
                    (suffix_op.Unary
                      tok: <Id.VTest_ColonHyphen ':-'>
                      arg_word: {<_tmp> <Id.Lit_Slash '/'> <vm-baseline>}
                    )
                )
              }
            )
            (C {<local>} 
              {<Id.Lit_VarLike 'name='> 
                (command_sub
                  left_token: <Id.Left_DollarParen '$('>
                  child: (C {<basename>} {($ Id.VSub_DollarName '$provenance')})
                )
              }
            )
            (C {<local>} 
              {<Id.Lit_VarLike 'prefix='> 
                (braced_var_sub
                  token: <Id.VSub_Name name>
                  suffix_op: (suffix_op.Unary tok:<Id.VOp1_Percent '%'> arg_word:{<.provenance.txt>})
                )
              }
            )
            (C {<local>} 
              {<Id.Lit_VarLike 'host='> 
                (command_sub
                  left_token: <Id.Left_DollarParen '$('>
                  child: (C {<hostname>})
                )
              }
            )
            (C {<local>} 
              {<Id.Lit_VarLike 'out_dir='> 
                (DQ ($ Id.VSub_DollarName '$base_dir') <'/'> ($ Id.VSub_DollarName '$prefix'))
              }
            )
            (C {<mkdir>} {<-p>} {($ Id.VSub_DollarName '$out_dir')})
            (command.Pipeline
              children: [
                (C {<cat>} {($ Id.VSub_DollarName '$provenance')})
                (command.WhileUntil
                  keyword: <Id.KW_While while>
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (C {<read>} {<Id.Lit_Underscore _>} {<Id.Lit_Underscore _>} 
                              {<Id.Lit_Underscore _>} {<sh_path>} {<shell_hash>}
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  body: 
                    (command.DoGroup
                      children: [
                        (C {<local>} 
                          {<Id.Lit_VarLike 'sh_name='> 
                            (command_sub
                              left_token: <Id.Left_DollarParen '$('>
                              child: (C {<basename>} {($ Id.VSub_DollarName '$sh_path')})
                            )
                          }
                        )
                        (C {<local>} 
                          {<Id.Lit_VarLike 'out='> 
                            (DQ ($ Id.VSub_DollarName '$out_dir') <'/'> (${ Id.VSub_Name sh_name) <-> 
                              (${ Id.VSub_Name shell_hash) <.txt>
                            )
                          }
                        )
                        (command.Simple
                          words: [
                            {($ Id.VSub_DollarName '$sh_path')}
                            {<-c>}
                            {(SQ <'sleep 0.001; cat /proc/$$/status'>)}
                          ]
                          redirects: [
                            (redir
                              op: <Id.Redir_Great '>'>
                              loc: (redir_loc.Fd fd:1)
                              arg: {($ Id.VSub_DollarName '$out')}
                            )
                          ]
                          do_fork: T
                        )
                      ]
                    )
                )
              ]
              negated: F
            )
            (C {<echo>})
            (C {<echo>} {(DQ ($ Id.VSub_DollarName '$out_dir') <':'>)})
            (C {<ls>} {<-l>} {($ Id.VSub_DollarName '$out_dir')})
          ]
        )
    )
    (command.ShFunction
      name: demo
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<-a>} 
              {<Id.Lit_VarLike 'job_dirs='> 
                (sh_array_literal
                  left: <Id.Op_LParen _>
                  words: [{($ Id.VSub_DollarName '$BASE_DIR') <'/lisa.2017-'> <Id.Lit_Star '*'>}]
                )
              }
            )
            (C {<local>} {<Id.Lit_VarLike 'dir1='> ($ Id.VSub_DollarName '$BASE_DIR') <'/stage1'>})
            (C {<local>} {<Id.Lit_VarLike 'dir2='> ($ Id.VSub_DollarName '$BASE_DIR') <'/stage2'>})
            (C {<mkdir>} {<-p>} {($ Id.VSub_DollarName '$dir1')} {($ Id.VSub_DollarName '$dir2')})
            (command.Simple
              words: [
                {<'benchmarks/virtual_memory.py'>}
                {<baseline>}
                {
                  (braced_var_sub
                    token: <Id.VSub_Name job_dirs>
                    bracket_op: 
                      (bracket_op.ArrayIndex
                        expr: (arith_expr.Unary op_id:Id.Node_UnaryMinus child:{<Id.Lit_Digits 1>})
                      )
                  )
                }
              ]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {($ Id.VSub_DollarName '$dir1') <'/vm-baseline.csv'>}
                )
              ]
              do_fork: T
            )
            (C {<'benchmarks/report.R'>} {<vm-baseline>} {($ Id.VSub_DollarName '$dir1')} 
              {($ Id.VSub_DollarName '$dir2')}
            )
          ]
        )
    )
    (command.ShFunction
      name: stage1
      body: 
        (BraceGroup
          children: [
            (C {<local>} 
              {<Id.Lit_VarLike 'raw_dir='> 
                (braced_var_sub
                  token: <Id.VSub_Number 1>
                  suffix_op: 
                    (suffix_op.Unary
                      tok: <Id.VTest_ColonHyphen ':-'>
                      arg_word: {($ Id.VSub_DollarName '$BASE_DIR') <Id.Lit_Slash '/'> <raw>}
                    )
                )
              }
            )
            (C {<local>} {<Id.Lit_VarLike 'out='> ($ Id.VSub_DollarName '$BASE_DIR') <'/stage1'>})
            (C {<mkdir>} {<-p>} {($ Id.VSub_DollarName '$out')})
            (C {<local>} {<-a>} 
              {<Id.Lit_VarLike 'm1='> 
                (sh_array_literal
                  left: <Id.Op_LParen _>
                  words: [{<'../benchmark-data/vm-baseline/flanders.'> <Id.Lit_Star '*'>}]
                )
              }
            )
            (C {<local>} {<-a>} 
              {<Id.Lit_VarLike 'm2='> 
                (sh_array_literal
                  left: <Id.Op_LParen _>
                  words: [{<'../benchmark-data/vm-baseline/lisa.'> <Id.Lit_Star '*'>}]
                )
              }
            )
            (C {<local>} {<-a>} 
              {<Id.Lit_VarLike 'latest='> 
                (sh_array_literal
                  left: <Id.Op_LParen _>
                  words: [
                    {
                      (braced_var_sub
                        token: <Id.VSub_Name m1>
                        bracket_op: 
                          (bracket_op.ArrayIndex
                            expr: (arith_expr.Unary op_id:Id.Node_UnaryMinus child:{<Id.Lit_Digits 1>})
                          )
                      )
                    }
                    {
                      (braced_var_sub
                        token: <Id.VSub_Name m2>
                        bracket_op: 
                          (bracket_op.ArrayIndex
                            expr: (arith_expr.Unary op_id:Id.Node_UnaryMinus child:{<Id.Lit_Digits 1>})
                          )
                      )
                    }
                  ]
                )
              }
            )
            (command.Pipeline
              children: [
                (C {<'benchmarks/virtual_memory.py'>} {<baseline>} 
                  {
                    (DQ 
                      (braced_var_sub
                        token: <Id.VSub_Name latest>
                        bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At)
                      )
                    )
                  }
                )
                (C {<tee>} {($ Id.VSub_DollarName '$out') <'/vm-baseline.csv'>})
              ]
              negated: F
            )
          ]
        )
    )
    (command.ShFunction
      name: print-report
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'in_dir='> ($ Id.VSub_Number '$1')})
            (C {<local>} {<Id.Lit_VarLike 'base_url='> (SQ <'../../web'>)})
            (command.Simple
              words: [{<cat>}]
              redirects: [
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      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='>
                        <Id.Right_DoubleQuote '"'>
                        <'text/javascript'>
                        <Id.Right_DoubleQuote '"'>
                        <' src='>
                        <Id.Right_DoubleQuote '"'>
                        ($ Id.VSub_DollarName '$base_url')
                        <'/table/table-sort.js'>
                        <Id.Right_DoubleQuote '"'>
                        <'></script>\n'>
                        <'    <link rel='>
                        <Id.Right_DoubleQuote '"'>
                        <stylesheet>
                        <Id.Right_DoubleQuote '"'>
                        <' type='>
                        <Id.Right_DoubleQuote '"'>
                        <'text/css'>
                        <Id.Right_DoubleQuote '"'>
                        <' href='>
                        <Id.Right_DoubleQuote '"'>
                        ($ Id.VSub_DollarName '$base_url')
                        <'/table/table-sort.css'>
                        <Id.Right_DoubleQuote '"'>
                        <' />\n'>
                        <'    <link rel='>
                        <Id.Right_DoubleQuote '"'>
                        <stylesheet>
                        <Id.Right_DoubleQuote '"'>
                        <' type='>
                        <Id.Right_DoubleQuote '"'>
                        <'text/css'>
                        <Id.Right_DoubleQuote '"'>
                        <' href='>
                        <Id.Right_DoubleQuote '"'>
                        ($ Id.VSub_DollarName '$base_url')
                        <'/benchmarks.css'>
                        <Id.Right_DoubleQuote '"'>
                        <' />\n'>
                        <'\n'>
                        <'  </head>\n'>
                        <'  <body>\n'>
                        <'    <p id='>
                        <Id.Right_DoubleQuote '"'>
                        <home-link>
                        <Id.Right_DoubleQuote '"'>
                        <'>\n'>
                        <'      <a href='>
                        <Id.Right_DoubleQuote '"'>
                        <'/'>
                        <Id.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'>
                      ]
                    )
                )
              ]
              do_fork: T
            )
            (C {<csv2html>} {($ Id.VSub_DollarName '$in_dir') <'/vm-baseline.csv'>})
            (command.Simple
              words: [{<cat>}]
              redirects: [
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      here_begin: {<EOF>}
                      here_end_span_id: 540
                      stdin_parts: [<'    <!-- <h3>Shell and Host Details</h3> -->\n'>]
                    )
                )
              ]
              do_fork: T
            )
            (command.Simple
              words: [{<cat>}]
              redirects: [
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      here_begin: {<EOF>}
                      here_end_span_id: 559
                      stdin_parts: [<'  </body>\n'> <'</html>\n'>]
                    )
                )
              ]
              do_fork: T
            )
          ]
        )
    )
    (command.ShFunction
      name: parser-dump-demo
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'out_dir='> <'_tmp/virtual-memory'>})
            (C {<mkdir>} {<-p>} {($ Id.VSub_DollarName '$out_dir')})
            (C {<local>} {<Id.Lit_VarLike 'input='> <'benchmarks/testdata/abuild'>})
            (C {<'bin/osh'>} {<--parser-mem-dump>} {($ Id.VSub_DollarName '$out_dir') <'/parser.txt'>} 
              {<-n>} {<--ast-format>} {<none>} {($ Id.VSub_DollarName '$input')}
            )
            (C {<grep>} {(SQ <'^Vm'>)} {($ Id.VSub_DollarName '$out_dir') <'/parser.txt'>})
          ]
        )
    )
    (command.ShFunction
      name: runtime-dump-demo
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'out_dir='> <'_tmp/virtual-memory'>})
            (C {<mkdir>} {<-p>} {($ Id.VSub_DollarName '$out_dir')})
            (C {<'bin/osh'>} {<--parser-mem-dump>} {($ Id.VSub_DollarName '$out_dir') <'/parser.txt'>} 
              {<--runtime-mem-dump>} {($ Id.VSub_DollarName '$out_dir') <'/runtime.txt'>} {<-c>} {(SQ <'echo $(echo hi)'>)}
            )
            (C {<grep>} {(SQ <'^Vm'>)} {($ Id.VSub_DollarName '$out_dir') <'/parser.txt'>} 
              {($ Id.VSub_DollarName '$out_dir') <'/runtime.txt'>}
            )
          ]
        )
    )
    (C {(DQ ($ Id.VSub_At '$@'))})
  ]
)