LNCD

Table of Contents

Table of Contents

  • Usage Profiling and benchmarking
    • Shell
      • Super Computer Slurm
      • hyperfine
    • R
    • python
  • LNCD Home
  • Administration
  • Notebooks
  • Journal Club Presentations
  • Publications
  • Current Projects
  • Completed Projects
  • Current Grants
  • Datasets by Project
  • Brain ROIs and Measures
  • ️Tools And Methods
  • Big Data
  • RA Homepage
  • Undergrad Resources
  • Recent Changes
  • Maintenance
  • Site Map
  • Random Page
LNCD
Docs » Usage Profiling and benchmarking

Usage Profiling and benchmarking

Shell

/usr/bin/time 1) can report total run time (“clock on the wall”) and memory (RSS = Resident Set Size)

/usr/bin/time -v perl -e '"a"x(1024**3);' |& grep -Pi 'max|wall'
#        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.40
#        Maximum resident set size (kbytes): 1053908

Super Computer Slurm

When run with slurm, eg. Pittsburgh Super Computer

 sacct -j $jobid --format=JobID,MaxRSS,AveRSS,TotalCPU,Elapsed

hyperfine

For smaller jobs, hyperfine runs many time for a more rigorous estimate.

hyperfine 'sleep .5' 'sleep .55'
Benchmark 1: sleep .5
  Time (mean ± σ):     502.3 ms ±   0.6 ms    [User: 1.6 ms, System: 0.8 ms]
  Range (min … max):   501.7 ms … 503.2 ms    10 runs
 
Benchmark 2: sleep .55
  Time (mean ± σ):     552.6 ms ±   0.5 ms    [User: 1.5 ms, System: 1.0 ms]
  Range (min … max):   551.8 ms … 553.4 ms    10 runs
 
Summary
  sleep .5 ran
    1.10 ± 0.00 times faster than sleep .55

R

GNU R can use microbenchmark

microbenchmark::microbenchmark(sqrt100 = sqrt(runif(100)))

#Unit: microseconds
#    expr   min    lq    mean median    uq    max neval
# sqrt100 5.769 5.911 6.82513  6.071 6.445 46.451   100

python

import timeit
timeit.timeit('numpy.sqrt(numpy.random.uniform(size=100))',
              setup='import numpy')
# 3.9988546459935606
1)
NB. not bash built-in time, need explicit path
Previous Next