github.com/hanwen/go-fuse@v1.0.0/example/benchmark.sh (about)

     1  #!/bin/sh
     2  
     3  # Runtime is typically dominated by the costs of GetAttr (ie. Stat),
     4  # so let's time that.  We use zipfs which runs from memory to minimize
     5  # noise due to the filesystem itself.
     6  
     7  if [ "$1" == "" ] ; then
     8    echo "Usage: benchmark.sh ZIPFILE"
     9    echo "The zipfile should be large (> 10000 files)."
    10    exit 2
    11  fi
    12  
    13  set -eux
    14  
    15  ZIPFILE=$1
    16  shift
    17  CPU_COUNT=$(grep '^processor'  /proc/cpuinfo | wc -l)
    18  export GOMAXPROCS=${CPU_COUNT}
    19  
    20  DELAY=5
    21  
    22  gomake -C zipfs
    23  gomake -C bulkstat
    24  
    25  MP=/tmp/zipbench
    26  fusermount -u ${MP} || true
    27  mkdir -p ${MP}
    28  
    29  ZIPFS=$PWD/zipfs/zipfs
    30  BULKSTAT="$PWD/bulkstat/bulkstat -threads ${CPU_COUNT}"
    31  
    32  cd /tmp
    33  
    34  ${ZIPFS} ${MP} ${ZIPFILE} >& zipfs.log &
    35  
    36  
    37  # Wait for FS to mount.
    38  sleep ${DELAY}
    39  find ${MP} > /tmp/zipfiles.txt
    40  fusermount -u ${MP}
    41  
    42  # Run vanilla: block box measurement.
    43  ${ZIPFS} ${MP} ${ZIPFILE} >& zipfs.log &
    44  
    45  # Wait for zipfs to unpack and serve the file.
    46  sleep ${DELAY}
    47  
    48  # Performance number without 6prof running
    49  echo -e "\n\n"
    50  ${BULKSTAT} -runs 5 /tmp/zipfiles.txt
    51  echo -e "\n\n"
    52  
    53  # Run 6prof
    54  6prof -p $! -d 20 -t 3 -hs -l -h -f >& /tmp/zipfs.6prof &
    55  sleep 0.1
    56  
    57  # Feed data to 6prof
    58  ${BULKSTAT} -runs 3 /tmp/zipfiles.txt
    59  
    60  echo -e "\n\n"
    61  
    62  fusermount -u ${MP}
    63  
    64  # Now run with internal monitoring.
    65  ${ZIPFS} -latencies ${MP} ${ZIPFILE} >& zipfs.log &
    66  
    67  sleep ${DELAY}
    68  
    69  # Measurements.
    70  ${BULKSTAT} -runs 5 /tmp/zipfiles.txt
    71  
    72  # Dump internal measurements.
    73  cat ${MP}/.debug/*
    74  
    75  
    76